IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_gen_cstmodify0]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_gen_cstmodify0]
GO
create procedure [dbo].[mps_gen_cstmodify0](
@cmpid int,
@ctid int
)
as
begin
set nocount on
declare @s1 nvarchar(100) 
declare @tbname varchar(50)
declare @dbname varchar(50)
declare @fkey   varchar(50) 
declare @mctid int 
set @mctid = @ctid * (-1) 
exec sys_sql_getTableNamePk @cmpid,'cst',@mctid,0,@tbname output,@fkey output ,@dbname output 

declare @sql nvarchar(MAX) 
set @sql = N'
-- 生成时间:'+convert(varchar(20),getdate(),120)+N' by ebs-core  
'
if (dbo.checkprocedure(@tbname+'_modify_0')=0) set @sql=@sql+'alter ' else set @sql=@sql+'create '
set @sql = @sql+' procedure '+@tbname+N'_modify_0(
     @ccid bigint, 
     @idname varchar(50), 
     @text text ) 
as  
begin  
declare @id3 bigint 
select top 1 @id3 = cc3_id from '+@dbname+@tbname+N'_0 where cc3_ccid = @ccid  and cc3_idname=@idname 
set @id3 = isnull(@id3, 0) 
if (@id3 = 0) 
begin 
insert into '+@dbname+@tbname+N'_0(cc3_ccid, cc3_idname, cc3_text) values(@ccid, @idname, @text) 
end else 
begin 
update '+@dbname+@tbname+'_0 set cc3_text = @text where cc3_id = @id3 
end 
end 
 '
exec myprint @sql 
execute(@sql)
-- 生成mps_sql 
set @sql = ' exec mps_sys_gen_mpssql '+CONVERT(varchar(10),@cmpid)+','''+@tbname+N'_modify_0'',
''@ccid bigint,@idname varchar(50),@text text''' 
execute(@sql)
set nocount off 
end