sql存储过程输出


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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM