Woah. Why is your trigger FOR UPDATE
Yet your email body is talking about a new ticket being created? Consider using FOR INSERT
Just in case that's not the only issue, everything below is still worth a read.
First it's entirely possible that your trigger is firing but not doing anything. never assume your update/insert/delete is only one record.
I see your code is checking for a single row affected but if there are two rows updated at the same time, nothing will happen. It would probably be better to code a loop if you want email to be send for every update.
SQL doesn't log that a trigger is firing, Triggers are as transactional as the SQL that triggers them. In other words, if your update worked, your trigger worked. In this case, either you are doing a multi-row update that your trigger is skipping or you've not configured xp_sendmail
correctly. I suspect the latter.
I would recommend against using xp_sendmail
. For starters, it's deprecated now. It's also a hassle to configure, it requires installing a MAPI client (like outlook) on your database server.
The preferred way to send email from the database these days is using sp_dbmail
. Rather than SQL server sending commands to a local install of outlook express, sp_dbmail
will simply use SMTP.
Also, sp_dbmail will log your emails that are sent. It keeps copies of outgoing e-mail messages and stores them in the following tables:
sysmail_allitems
, sysmail_sentitems
, sysmail_unsentitems
, sysmail_faileditems
.
It becomes much easier to troubleshoot your actual issue. Using sp_dbmail
Sent item statuscan be seen in sysmail_mailitems table. if sent_status
is 1 then it sent successfully, failures are 2 and 3 is unsent.
Anyway, read all about dbmail here
And here's a video describing how to configure DB mail in SQL 2008