weixin_46392451
2021-06-16 00:13
采纳率: 90%
浏览 45

SqlServer 2008:写一个插入时生成流水号的存储过程,错误提示有参数没有提供,求助!

create procedure insert_booking_procedure 
@bno varchar(15),
@pno int,
@dno int,
@condition varchar(10),
@number varchar(2),
@date varchar(10),
@period varchar(2),
@bookableno varchar(15),
@createtime smalldatetime
as
begin
declare @id varchar(15),@id1 int,@head varchar(8)

set @head=convert(varchar,getdate(),112)
select @id=max(bookableno) from booking where bookableno like @head+'%'
if @id is null
begin
    set @id1=0
end

else
begin
	set @id1=cast(substring(@id,9,5) as int)
end

set @bno=@head+right('00000'+cast(@id1 as varchar),5)
set @createtime=GETDATE()

insert 
into booking 
(bno,pno,dno,condition,number,date,period,bookableno,createtime) 
values(@bno ,@pno, @dno, @condition, @number, @date, @period, @bookableno, @createtime)
end

 

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题