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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 rollback after test email sent

Author  Topic 

dlh
Starting Member

28 Posts

Posted - 2010-07-26 : 17:22:55
I'm building/testing a complicated update query inside a transaction and I'm using dbmail to send someone a log of the changes.

BEGIN TRANSACTION
...
EXEC msdb.dbo.sp_send_dbmail
...
ROLLBACK TRANSACTION

I think the mail is being queued correctly but the rollback prevents me from seeing the test output.

Can anyone recommend a strategy that lets me rollback everything while I'm in test-mode but still send out an email?

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2010-07-26 : 19:28:04
I believe that a table variable falls outside of a transaction so you could insert your results into a table variable, execute your rollback and still display the results from the table variable.

=======================================
A couple of months in the laboratory can save a couple of hours in the library. -Frank H. Westheimer, chemistry professor (1912-2007)
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-07-27 : 01:40:16
"I believe that a table variable falls outside of a transaction "

That is definitely the case
Go to Top of Page
   

- Advertisement -