IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_gen_employeeupdatearchsource]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_gen_employeeupdatearchsource]
GO
CREATE PROCEDURE [dbo].[mps_gen_employeeupdatearchsource]    
@cmpid int,    
@bcid int  ,  
@dpid int   
AS    
BEGIN    
 SET NOCOUNT ON;    
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
 declare @source varchar(max)    
     
 --生成部门选择的source    
 set @source=''    
 select @source+=dp_depart+'='+CONVERT(varchar,dp_id)+'|'     
 from mps_depart     
 where dp_bcid=@bcid    
 and dp_cmpid=@cmpid     and dp_isdepart=0 
 select @source as source    
   
 --生成岗位选择的source    
 set @source=''    
 select @source+=ot_title+'='+CONVERT(varchar,ot_id)+'|'    
 from mps_depart_title ,mps_title  
 where ot_cmpid=@cmpid    
 and ot_id = dt_otid  
 AND dt_dpid = @dpid  
   
 select @source as source    
 --生成角色选择的source    
 set @source=''    
 select @source+=rl_title+'='+CONVERT(varchar,rl_value)+'|'    
 from mps_role    
 where rl_cmpid=@cmpid    
 select @source as source    
   
 --生成管理等级选择的source  
 set @source=''    
 select @source+=mg_caption+'='+CONVERT(varchar,mg_grade)+'|'    
 from mps_manage_grade    
 where mg_cmpid=@cmpid    
 select @source as source   
 --生成岗位等级选择的source  
 set @source=''    
 select @source+=bg_caption+'='+CONVERT(varchar,bg_grade)+'|'    
 from mps_profession_grade    
 where bg_cmpid=@cmpid    
 select @source as source   
   
END