Transaction:
- Sequence of one or more SQL statements that are treated as a single unit or work.
- Can consist of one or more data manipulation language (DML) statements, such as 'INSERT', 'UPDATE', or 'DELETE', or DDL statements such as 'CREATE', "ALTER', or 'DROP'.
- SYNTAX:
BEGIN TRANSACTION
-- SQL statements here
IF @@ERROR <> 0
BEGIN
ROLLBACK TRANSACTION
END
ELSE
BEGIN
COMMIT TRANSACTION
END
- Commit: Command used to finalized a transaction and make changes permanent.
- Rollback: Command used to undo the transaction that has not been committed yet.
Comments
Post a Comment