1.存储过程写法

create procedure [dbo].[Y_GetICBillNo]
@IsSave smallint,
@FBillType int,
@BillID VARCHAR (50) output
as
declare @BillID2 VARCHAR (50)

--赋值@BillID
select @BillID =isnull(FPreLetter,'') + right(fformat + convert(VARCHAR (20),isnull(FCurNo+1,1) + isnull(FSufLetter,'') ) ,len(fdesc)-CHARINDEX('+',fdesc) +len(isnull(FSufLetter,'') ) )
,@BillID2= isnull(FPreLetter,'') + '+' + right(fformat + convert(VARCHAR (20),isnull(FCurNo+1,1) + isnull(FSufLetter,'') ) ,len(fdesc)-CHARINDEX('+',fdesc) +len(isnull(FSufLetter,'') ) )
from ICBillNo
where FBillId= @FBillType

begin tran
if @IsSave=1
update ICBillNo set FCurNo=FCurNo+1,FDesc=@BillID2 where FBillId = @FBillType

if @@error=0 commit
else
begin
rollback
select @BillID=''
end
return

--返回值

2.调用该存储过程

declare @BillID  varchar(50)

exec  Y_GetICBillNo  12,11,@BillID

select @BillID

相关文章:

  • 2021-10-01
  • 2022-02-12
  • 2022-12-23
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
猜你喜欢
  • 2021-08-14
  • 2022-12-23
  • 2021-10-11
  • 2021-08-14
  • 2021-09-06
  • 2022-12-23
相关资源
相似解决方案