IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[order_256_set_subform]') AND type = 'P')
DROP PROCEDURE [dbo].[order_256_set_subform]
GO
CREATE procedure order_256_set_subform(@ordid bigint)asbegindeclare @t table(tmpid int)insert into @t(tmpid) select 680from order_256where ord_id=@ordid and (ord_rblx='售后服务店长日报');insert into @t(tmpid) select 682from order_256where ord_id=@ordid and (ord_rblx='工程师日报')declare @tmp int select @tmp=count(1) from @tif (@tmp=1) update order_256 set ord_templateid=tmp_id , ord_template=tmp_caption from mps_template,@t where ord_id=@ordid and tmp_id=tmpid  end