Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Laith Scofield
Starting Member
10 Posts |
Posted - 2010-08-11 : 15:53:13
|
| Hi guysam a beginner with sql and i reading a book about sql for wroxi got read something called "Sql transaction" and i didn't catch it oncan you explain to me what does "Sql transaction" mean ???and I'll be so grateful..."It's fine to celebrate success but it is more important to heed the lessons of failure."Bill Gates |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-08-11 : 17:29:28
|
The term "Transaction" can mean 2 things.Any operation that modifies data can be termed a transaction.More commonly however, we mean an ATOMic operation, or set of operations, that can be committed or rolled back.One common example of a transaction occurs when you transfer funds from one bank account to another.UPDATE Checking SET amount = amount - 100;UPDATE Savings SET amount = amount + 100; We need to be certain that if either statement fails (for whatever reason) that they BOTH fail. So we wrap it in a transaction...BEGIN TRANSACTIONUPDATE Checking SET amount = amount - 100;UPDATE Savings SET amount = amount + 100;IF @@ERROR <> 0BEGIN ROLLBACK RETURN 0ENDCOMMITRETURN 1 For more info, please review these:http://msdn.microsoft.com/en-us/library/ms188929.aspxhttp://en.wikipedia.org/wiki/Database_transaction |
 |
|
|
Laith Scofield
Starting Member
10 Posts |
Posted - 2010-08-11 : 18:19:54
|
| thanks dude.."It's fine to celebrate success but it is more important to heed the lessons of failure."Bill Gates |
 |
|
|
|
|
|