IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_groupbranch]') AND type = 'V')
DROP VIEW [dbo].[mps_groupbranch]
GO
CREATE VIEW [dbo].[mps_groupbranch]  
AS  
SELECT bc_id, bc_cmpid, bc_code, bc_incode, bc_company, bc_level, bc_order, bc_display, bc_fullname ,bc_dingid
FROM   dbo.mps_branch  
union   
select 0 bc_id , cmp_id bc_cmpid ,cmp_groupcode bc_code , cmp_groupcode bc_incode , cmp_grouptitle bc_company , 0 bc_level , 0 bc_order,   
cmp_grouptitle bc_display , cmp_grouptitle bc_fullname ,cmp_dingid  bc_dingid
from ebs_kernel.dbo.pub_company
where cmp_goto=0