IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[order_69_set_subform]') AND type = 'P')
DROP PROCEDURE [dbo].[order_69_set_subform]
GO
CREATE procedure order_69_set_subform(@ordid bigint)asbegindeclare @t table(tmpid int)insert into @t(tmpid) select 497from order_69where ord_id=@ordid and (ord_yglx='行政');insert into @t(tmpid) select 498from order_69where ord_id=@ordid and (ord_yglx='营运')declare @tmp int select @tmp=count(1) from @tif (@tmp=1) update order_69 set ord_templateid=tmp_id , ord_template=tmp_caption from mps_template,@t where ord_id=@ordid and tmp_id=tmpid  end