home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 18,038 of 19,505   
   Erland Sommarskog to Travis Crow   
   Re: Sending an email from a trigger   
   17 Dec 10 23:34:40   
   
   From: esquel@sommarskog.se   
      
   Travis Crow (noreply@invalid.org) writes:   
   > I have a situation where I want to be able to send an email using   
   > "execute msdb.dbo.sp_send_dbmail" when something has gone wrong with the   
   > validation in the trigger.   
   >   
   > Unfortunately if I raise an error and rollback the transaction, the email   
   > does not get sent.   
      
   This is because sp_send_dbmail queues the mail on a Service Broker queue   
   which is transactional.   
      
   You could to things in this order:   
      
   1) Rollback   
   2) Send mail   
   3) Raiserror   
      
      
      
      
   --   
   Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se   
      
   Links for SQL Server Books Online:   
   SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx   
   SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca