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 |
|
jag_chat
Starting Member
3 Posts |
Posted - 2004-01-28 : 21:35:12
|
| I wrote a store procedure like the followingcreate procedure....asbegindeclare @e intselect @e = 0begin transinsert.....if @@ERROR<>0begin@e = @@ERRORprint "...."endif @@ERROR<>0begin@e = @@ERRORprint "...."endif @e=0 thencommit transactionelserollback transactionreturn 0it is not working....when any error (especially wrong table name)...it is raising an error and no commit or rollback getting executed in the second statement....no other setting is made apart from the above code. |
|
|
jek
Starting Member
9 Posts |
Posted - 2004-01-29 : 00:55:43
|
| HiFor this to work, you should save the @@ERROR in a variable. (Reason is @@ERROR contains error/result of most recently executed code.)declare @ERRORID intinsert.....--- ** save the error before using it anywhere **set @ERRORID=@@ERRORif @ERRORID<>0begin print "error encountered" |
 |
|
|
|
|
|