T-SQL Transaction Scope - practice safe SQL.
BEGIN TRANSACTION
BEGIN TRY
--ETL Stuff
--If no errors the transaction will commit
--If there are errors the transaction will be rolled back and display error
END TRY
BEGIN CATCH
SELECT ERROR_MESSAGE() AS ErrorMessage;
IF @@TRANCOUNT > 0
ROLLBACK TRANSACTION;
END CATCH
IF @@TRANCOUNT > 0
COMMIT TRANSACTION
GO
Comments
Post a Comment