dbTalk Databases Forums  

SQL Mail Task - may run it by table trigger and send email with insert information?

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss SQL Mail Task - may run it by table trigger and send email with insert information? in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Dmitry N.Ananyev
 
Posts: n/a

Default SQL Mail Task - may run it by table trigger and send email with insert information? - 07-14-2006 , 01:07 AM






SQL Mail Task - may run it by table trigger and send email with insert
information?

Is it possible?



Are anywhere examples?





Reply With Quote
  #2  
Old   
Davide
 
Posts: n/a

Default Re: SQL Mail Task - may run it by table trigger and send email with insert information? - 07-14-2006 , 04:10 AM






Hello Dmitry N.Ananyev,

Quote:
SQL Mail Task - may run it by table trigger and send email with insert
information?

Is it possible?

Are anywhere examples?

Hi, you could create a trigger on INSERT operation; in this trigger you could
execute the extended sp 'xp_sendmail' in which (for example) you send a
mail with the number of row inserted.
Just like this:


CREATE TRIGGER MyTrigger
ON dbo.Table1
FOR INSERT
AS


declare @rowsins int
declare @rowsinsSTR varchar(255)

SELECT @rowsins = count(*) FROM inserted
set @rowsinsSTR = 'Inserted ' + CAST( @rowsins AS varchar(255)) + ' rows'


EXEC master..xp_sendmail
@recipients = 'themailaddresses',
@message = @rowsinsSTR,
@width=100,
@subject = 'Inserted rows '


bye




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.