Can a SQL Server trigger send me an email?

I want to send an email from Triggeron my computer running SQL Server 2008. The email data will be mainly part of the Trigger information.

Can someone provide a simple or sample code on how to do this, please? For example. what is called a system stored procedure? Etc.

I did not configure SQL mail and stuff, so I assume that it is built-in, and I can use it. But just to make sure: do I need to install any additional software on the server?

+5
source share
2 answers

(MaryM), .

USE pubs
IF EXISTS (SELECT name FROM sysobjects
      WHERE name = 'reminder' AND type = 'TR')
   DROP TRIGGER reminder
GO
CREATE TRIGGER reminder
ON titles
FOR INSERT, UPDATE, DELETE 
AS
   EXEC master..xp_sendmail 'MaryM', 
      'Don''t forget to print a report for the distributors.'
GO

: MSDN

+5

. // . , , .

, , TransactSQL - !

+3

All Articles