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

Corporate Intranet Information Architecture – a Publishing Site

No Search Results in SharePoint Contextual Search OSSSearchResults.aspx

The long sad road to getting Metastorm, SharePoint, and Kerberos to work together in a multiple server farm.