求SQL server 存储过程代码

2024-11-23 19:28:03
推荐回答(2个)
回答1:

ALTER PROCEDURE [dbo].[Proc_GetBillNumber]

@Bill_Head varchar(50)

AS

DECLARE @MyErr NVARCHAR(500)

Begin Transaction

insert into ...
update ....
COMMIT TRANSACTION

IF @@ERROR <> 0 --运行错误
BEGIN
ROLLBACK TRANSACTION
SET @MyErr = CAST(@@Error AS Nvarchar(500))
RAISERROR(@Myerr,16,1)
RETURN
END

END
ELSE
BEGIN
ROLLBACK TRANSACTION
RETURN -1;
END

回答2:

目的呢?