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 |
|
slimt_slimt
Aged Yak Warrior
746 Posts |
Posted - 2008-05-06 : 13:54:11
|
I have a simple update:begin transactionupdate table1 set column1 = 10 where column2 = 'ABC'If @@Error > 0 thenrollback transactionelsecommit transaction print 'show all updated fields'go What i want to achieve is if transaction is successful, i would like to see which fields were updated (in form of report or something like following below:column0 | column1 | column2 ---------------------------1 | 10 | ABC21 | 10 | ABC12 | 10 | ABC251 | 10 | ABC4 row(s) updated.There should be a clause like OUTPUT, but don't know how to use it :-(thank you |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-05-06 : 14:13:45
|
| You do not need to use a transaction when you have only one DML statement. Check out the "OUTPUT Clause" topic in SQL Server Books Online for how to use it. There are plenty of examples in there.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
|
|
|
|