Microsoft SQL Server Transaction management statements

Transaction management statements

You use the following transaction management statements with transaction objects to manage connection and transactions for a SQL Server database:

  • CONNECT

  • COMMIT

  • DISCONNECT

  • ROLLBACK

Transaction management in triggers

You should not use transaction statements in triggers. A trigger is a special kind of stored procedure that takes effect when you issue a statement such as INSERT, DELETE, or UPDATE on a specified table or column. Triggers can be used to enforce referential integrity.

For example, assume that a certain condition within a trigger is not met and you want to execute a ROLLBACK. Instead of coding the ROLLBACK directly in the trigger, you should use RAISERROR and test for that particular return code in the DBMS-specific return code (SQLDBCode) property within the referenced transaction object.

See also

Microsoft SQL Server Using CONNECT, COMMIT, DISCONNECT, and ROLLBACK