BEGIN TRY
BEGIN TRAN
--put queries here
COMMIT;
END TRY
BEGIN CATCH
IF @@TRANCOUNT>0
BEGIN
SELECT @@ERROR,ERROR_MESSAGE ( )
ROLLBACK;
END
END CATCH
any one can use above code to manage transaction as well as error handling in sql server.
BEGIN TRY BEGIN TRAN --put queries here COMMIT; END TRY BEGIN CATCH IF @@TRANCOUNT>0 BEGIN SELECT @@ERROR,ERRO...
No comments:
Post a Comment