2013年12月18日 星期三

mssql-transaction



Transactions
Transactions are used when you need to perform more than one operation such
as Insert, Update, or Delete or when you want to validate that the result is what
it is expected to be. If everything is good, you commit the transaction; if something
goes wrong, you can roll back the transaction and everything goes back to what it
was before.
To start a transaction, use the following command:
Begin tran T1
Here, T1 is the name of the transaction and can be any name you want. If everything
is good with the operations and you want to commit the transaction, you use the
following command:
Commit tran T1
If you want to cancel the transaction and go back to what it was before, you use
the following command:
Rollback tran T1

沒有留言:

張貼留言