How to use "Transaction and Rollback" in SQL SERVER stored Procedure

Hello Techies, 

Today i am going to learn "how to use Transaction in Stored procedure".
There syntax is simple which is all follows,


Create Proc sp_ProcName
    @ID INT
AS
BEGIN
BEGIN TRAN
BEGIN TRY
                   Update Table Set Value='Transaction Test' Where ID=@ID 
       COMMIT TRAN
          END TRY
BEGIN CATCH

    ROLLBACK TRAN

END CATCH
END
How to use "Transaction and Rollback" in SQL SERVER stored Procedure How to use "Transaction and Rollback" in SQL SERVER stored Procedure Reviewed by Ashwani on November 21, 2018 Rating: 5

No comments:

Powered by Blogger.