sql server - TSQL logging inside transaction -


i'm trying write log file inside transaction log survives if transaction rolled back.

--start code

begin tran

insert [something] dbo.logtable

[[main code here]]

rollback

commit

-- end code

you log before transaction starts not easy because transaction starts before s-proc run (i.e. code part of bigger transaction)

so, in short, there way write special statement inside transaction not part of transaction. hope question makes sense.

use table variable (@temp) hold log info. table variables survive transaction rollback.

see this article.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -