Groups | Blog | Home
all groups > sql server programming > february 2007 >

sql server programming : Rollback whole transaction save/keep error message/error severity information


Bob
2/8/2007 10:38:21 PM
Hi all,

In SQL 2005, is it possible to rollback the entire transaction but
save/keep the system generated error message/error severity
information some where? I tried to store the error message in local
memory but once rollback I lost it.

Any ideas would be highly appreciated.

Thanks.
Adi
2/8/2007 11:18:33 PM
[quoted text, click to view]

I don't understand what you mean when you write that you tried to
store the error information in memory but after rollback the
information is gone. If you rollback a transaction it does not
effect variables (including table variables) at all.

SQL Server 2005 introduced new error handling functions that we can
use in order to get information about run time errors that occurred
during the code's run time. Using the try catch block it is very easy
to rollback the transaction and then store the information about the
error in a logging table. I suggest that you'll have a look in BOL
for explanation and example of the new try catch blocks (it also
includes explanation and example of 6 new error handling functions
that give you plenty of information about the error).

Adi
xyb
2/8/2007 11:28:03 PM
declare @localv int
begin tran
select top 10 * from articles
raiserror('error raised here',16,1)
select @localv =3D @@error
rollback tran
print @localv
On 2=D4=C29=C8=D5, =CF=C2=CE=E72=CA=B138=B7=D6, "Bob" <ausgood...@hotmail.c=
[quoted text, click to view]

AddThis Social Bookmark Button