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 |
|
turj
Starting Member
6 Posts |
Posted - 2007-11-21 : 03:37:16
|
| hi,I need some example for a simple transaction, (I looked in msdn and I didn't understood this.)lets say I have 2 update queries. I want to run this queries in a transaction, and make it rollback if one of the updates failed.I'm a developer and using php to exec all the queries, so I need a simple answer from the transaction, one row with one column the can be 'success' or 'failed.' thats it.thanks. |
|
|
cas_o
Posting Yak Master
154 Posts |
Posted - 2007-11-21 : 04:19:16
|
Something like this should work.begin tran t1update table set column = value where column = criteria if @@error <> 0begin rollback tran t1 select 'failed' returnendupdate table2 set column = value where column = criteria if @@error <> 0begin rollback tran t1 select 'failed' returnendelsebegin commit tran t1 select 'success' returnend ;-]... Quack Waddle |
 |
|
|
|
|
|