The cleanest method I know of is to store whatever you need to log in a table variable and use that
information after your ROLLBACK. Obvious scope repercussions, of course.

Signature
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
> We have a stored procedure and would like to register some information even if the stored
> procedure is rolled back.
[quoted text clipped - 15 lines]
>
> ben brugman
ben brugman - 18 Mar 2008 17:27 GMT
> The cleanest method I know of is to store whatever you need to log in a
> table variable and use that information after your ROLLBACK. Obvious scope
> repercussions, of course.
There is no control after the Rollback, until the next call and because of
the rollback the process stops. So in that case I have to wait for a manual
restart and wait for the next call.
Isn't there a way to write for example into another db (e.g. tempdb) and
keep that 'alive' even when there is a rollback ?
Ben
P.s. I thought about the client program to do two calls, one to register and
the second to execute. But that means an overhaul of the client software, at
the moment my company is not prepared to alter this part of the software at
this moment.
>> We have a stored procedure and would like to register some information
>> even if the stored procedure is rolled back.
[quoted text clipped - 19 lines]
>>
>> ben brugman
Another method is to raise an informative error to write it to errorlog. That
can't be rolled back. You probably don't want to write a huge amount of data
to your errorlog, and that info is not really accessible programatically.
Oracle has the so-called autonomous transaction which can be used for this
purpose. SQL Server doesn't support it.
Linchi
> We have a stored procedure and would like to register some information even
> if the stored procedure is rolled back.
[quoted text clipped - 19 lines]
>
> ben brugman
ben brugman - 18 Mar 2008 17:37 GMT
Both Tibor and Linchi,
Thanks for your anwsers, now I know I do not have to search for a function
that does not exist.
Probably was thinking of the autonomous (Oracle) function, because somewhere
in my memory was something that the requested function did exist. Should
have used a database instead of my memory.
Thanks,
ben brugman
> Another method is to raise an informative error to write it to errorlog.
> That
[quoted text clipped - 34 lines]
>>
>> ben brugman