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