Translate

Saturday, 18 November 2017

sql : use of try , catch in procedure

CREATE PROCEDURE DBO.USP_GETALL_DOC_ID
(
@ID INT
)
as
BEGIN
BEGIN TRAN MyTransation
BEGIN TRY
      BEGIN
      --*****************************
       SELECT * FROM MST_DOCUMENT WHERE ID=@ID ;
      --*****************************
      END
END TRY
BEGIN CATCH
IF XACT_STATE() <> 0
BEGIN
ROLLBACK TRAN  MyTransation
END
END CATCH

END

No comments:

Post a Comment