IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_ins_source]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_ins_source]
GO
 
CREATE procedure [dbo].[mps_ins_source](
@cmpid int ,
@objtype varchar(20),
@objid int,
@objid2 int,
@sourcename nvarchar(200),
@sourcecaption nvarchar(200),
@sourcefield varchar(50),
@sobjtype varchar(20),
@sobjid int,
@sobjid2 int,
@functionname varchar(100)  
) as
begin
if (not exists (select * from mps_biztype_source where bizs_bizid=@objid and bizs_type=@objtype and bizs_ord2tag=@objid2 and 
bizs_source=@sourcename)) 
begin
insert into mps_biztype_source(bizs_bizid,bizs_type,bizs_ord2tag,bizs_source,bizs_sourcecaption,bizs_sourcefield,bizs_sourcetype,bizs_ctgid,bizs_ctg2id,bizs_function) 
values(@objid,@objtype,@objid2,@sourcename,@sourcecaption,@sourcefield,@sobjtype,@sobjid,@sobjid2,@functionname) 
end 
-- 需要添加字段
if (@sourcefield>'') exec mps_new_fieldsinfo @cmpid ,@objtype ,@objid ,@objid2 ,@sourcefield , @sourcename ,'bigint',8,0,0
end