I need to understand about sql server transaction? I have gone through some articles available on google but I have n开发者_如何学Pythonot understood anything. Can anyone help me?
You can explicitly start a transaction by writing BEGIN TRANSACTION
. You end the transaction by running COMMIT TRANSACTION
.
Before the COMMIT
is run, the tables affected by your query can still be rolled back to the state they were in at the BEGIN TRANSACTION
point-in-time.
This is useful when you are writing a stored procedure that is pumping a lot of data between tables. By dividing it in smaller parts using transactions, the whole bunch does not need to be "rolled back" when the procedure hangs, an error occurs or you cancel it manually.
An article that elaborates on this is for example this one.
See Understanding Transactions.
Database Journal have a lot of good articles abaut mentoed subject
精彩评论