IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_set_form_template]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_set_form_template]
GO
create procedure [dbo].[mps_set_form_template](
@cmpid int ,
@bizid int ,
@ordid bigint 
) as
begin
declare @sql nvarchar(4000) 
select @sql = sql_text from mps_sql where sql_cmpid =@cmpid and sql_name='g_form_subtemplate_'
+convert(varchar(10),@bizid) 
set @sql = isnull(@sql,'') 
set @sql = replace(@sql,'{ordid}','@ordid') 
set @sql = replace(@sql,'{cmpid}','@cmpid') 
set @sql = replace(@sql,'{bizid}','@bizid') 
set @sql = replace(@sql,'{','') 
set @sql = replace(@sql,'}','') 
-- 不允许返回结果
set @sql = replace(@sql,'select @tmp tempcount','') 
set @sql = replace(@sql,'select a.*','select @tmp=1 ') 
set @sql = replace(@sql,'select 0 none','select @tmp=1 ')
exec sp_executesql @sql, N'@cmpid int ,@bizid int ,@ordid bigint', @cmpid,@bizid,@ordid 
end