I am coding SQL Server 2005 trigger. I want to make some logging during trigger execution, using INSERT statement into my log table. When there occurs error during execution
Don't know if I'm thinking too simple, but why not just change the order of the error handler to insert AFTER the rollback??
if (@err = 1)
begin
RAISERROR (@msg, 16, 1)
rollback transaction
INSERT INTO dbo.log(date, entry) SELECT getdate(), 'ERROR: ' + out from #output
return
end