IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_g_source_nof_comefrom]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_g_source_nof_comefrom]
GO
CREATE procedure [dbo].[mps_g_source_nof_comefrom](
@cmpid int ,
@biztype varchar(10),
@bizid int
) as
begin
set nocount on
select * from mps_biztype_comefrom 
where bs_bizid=@bizid and 
  (exists (select * from mps_biztype_comefrom_fieldmap where bsf_bsid=bs_id and bsf_use=0))
order by bs_scaption , bs_scaption_detail 
select  * from mps_biztype_source 
where bizs_type=@biztype and bizs_bizid=@bizid  and 
(bizs_source<>'上级' and bizs_source<>'上上级' and bizs_source<>'根级') order by bizs_source  


 -- get doc  文档只支持tag=0
 
select distinct 'doc' objtype , dc_tag  ctgid , 0 ctgid2 , dc_caption ctgcaption  from  mps_docctg where dc_cmpid=@cmpid and dc_tag=0 
-- get cst 
select distinct 'cst' objtype , ct_tag  ctgid , 0 ctgid2 , ct_caption ctgcaption  from  mps_csttype where ct_cmpid=@cmpid 
-- get prd 
select distinct 'prd' objtype , pc_tag  ctgid , 0 ctgid2 , pc_caption ctgcaption  from  mps_prdctg where pc_cmpid=@cmpid 
-- get equ 
select distinct 'equ' objtype , ec_tag  ctgid , 0 ctgid2 , ec_caption ctgcaption  from  mps_equctg where ec_cmpid=@cmpid 
-- get ext 
select distinct  'ext' objtype , etc_tag  ctgid , 0 ctgid2 , etc_caption ctgcaption  from  mps_ext_resource where etc_cmpid=@cmpid 
set nocount off
end