IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_insert_decision]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_insert_decision]
GO
CREATE procedure [dbo].[mps_insert_decision] 
@bizid int as
begin
  declare @bd_order int 
  select @bd_order = max(bd_order) from mps_biztype_decision where bd_bizid=@bizid 
  set @bd_order = isnull(@bd_order,0) 
  set @bd_order = @bd_order + 1 
  insert into mps_biztype_decision(bd_bizid) values(@bizid) 
  select top 1 @bd_order = bd_id  from  mps_biztype_decision where bd_bizid=@bizid order by bd_id desc 
  set nocount on
  select * from mps_biztype_decision where  bd_bizid=@bd_order  
  set nocount off
end