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

Popular posts from this blog

Metastorm - Open form in an action from a list or link

Corporate Intranet Information Architecture – a Publishing Site

No Search Results in SharePoint Contextual Search OSSSearchResults.aspx