February 23, 2004 at 6:37 pm
Hi All
Could you please help me with a insert trigger.
All it has to perform is to send an email to an email address, when a new record is inserted to the table. I think it should use master..xp_sendmail.
Thanks
February 23, 2004 at 8:22 pm
Try this:
CREATE TRIGGER trSendEmail ON dbo.TableName FOR INSERT
AS
EXEC master.dbo.xpsendmail @Recipients = 'myemail@mycompany.com', @Subject = 'Test'
Robert W. Marda
Billing and OSS Specialist - SQL Programmer
MCL Systems
February 24, 2004 at 6:19 pm
Hi Robert
Thanks very much, it worked like a treat.
Dinesh
February 25, 2004 at 8:06 am
Just a caution regarding this solution... see
http://www.sqlservercentral.com/columnists/sjones/worstpracticetriggeringexternalevents.asp
for how triggering external events can sometimes be a bad idea.
February 25, 2004 at 8:49 am
Yep becareful if you are doing this on a heavy used table it may get really bad. Try to use a separed table where you from the trigger store the changes and a separated process to handle the emails!
* Noel
February 25, 2004 at 8:57 am
I just read that article. Yes be sure you can accept the situations as explained in the article. Where I used it was on an isolated table that was used only by DBA's.
Robert W. Marda
Billing and OSS Specialist - SQL Programmer
MCL Systems
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply