it:ad:sql_server:howto:run_a_transaction_without_committing

IT:AD:SQL Server:HowTo:Run a Transaction Without Committing

Summary

Sometimes CodeFirst Migrations cocks up.

BEGIN TRANSACTION;
BEGIN TRY
    ...
END TRY
BEGIN CATCH
  SELECT ERROR_MESSAGE();
  SELECT ERROR_LINE();
  
    IF @@TRANCOUNT > 0
        ROLLBACK TRANSACTION;
END CATCH;

IF @@TRANCOUNT > 0
    -- COMMIT TRANSACTION;

  • /home/skysigal/public_html/data/pages/it/ad/sql_server/howto/run_a_transaction_without_committing.txt
  • Last modified: 2023/11/04 01:57
  • by 127.0.0.1