Author |
Topic |
hdv212
Posting Yak Master
140 Posts |
Posted - 2010-10-11 : 15:29:42
|
Hii have configured my sql server 2008 database mail. it works fine but when i use sp_send_dbmail which exists in msdb database, i got the error which i can not use statement in trigger :a USE database statement is not allowed in a procedure, function or trigger.can anybody have a solution ?thanks in advance |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2010-10-11 : 15:34:29
|
It is probably not (almost definitely not) a good idea to send email from a trigger.Probably a better idea would be to insert info about an email to be sent into a table, and have a scheduled job to axtually send the email.CODO ERGO SUM |
![Go to Top of Page Go to Top of Page](/forums/images/icon_go_up.gif) |
|
hdv212
Posting Yak Master
140 Posts |
Posted - 2010-10-11 : 16:02:55
|
Hii've solved my problem.i can use this proc without switching to msdb database :msdb..sp_send_dbmail -- works fineinstead of :use msdbexec sp_send_dbmailregards |
![Go to Top of Page Go to Top of Page](/forums/images/icon_go_up.gif) |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-11 : 16:16:39
|
Be sure that you never have hundreds or thousands of insert/updates at a time in your triggered table... No, you're never too old to Yak'n'Roll if you're too young to die. |
![Go to Top of Page Go to Top of Page](/forums/images/icon_go_up.gif) |
|
X002548
Not Just a Number
15586 Posts |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2010-10-11 : 17:25:18
|
quote: Originally posted by X002548no, no, sending an email from a trigger is a GREAT idea!...
Trying to pump up the consulting dollars?CODO ERGO SUM |
![Go to Top of Page Go to Top of Page](/forums/images/icon_go_up.gif) |
|
X002548
Not Just a Number
15586 Posts |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-12 : 12:43:41
|
hdv212, please excuse the unkindness of his behavior...![](/forums/images/icon_smile.gif) No, you're never too old to Yak'n'Roll if you're too young to die. |
![Go to Top of Page Go to Top of Page](/forums/images/icon_go_up.gif) |
|
X002548
Not Just a Number
15586 Posts |
|
Sachin.Nand
2937 Posts |
|
X002548
Not Just a Number
15586 Posts |
|
|