Creating Email Trigger

  • Hai,

    I want to create a Trigger on a Table. Whenever a New row inserted into the table, the trigger will fire an email to a Database Administrator. How can I accomplish this one?

    Thanks in advance

    Regards

    Vijay Babu

  • If your DBA allows it, you can call xp_sendmail to send the email, but access will need to be granted for that xp to any user that inserts into the table.

    What out if you are running sql 2000 sp2 as there are some issues with using that stored procedure.

    Steven

  • You also have the option of using CDOs AND CDONTs to send via SMTP. Or better to cut down on contention and other issues write message to a table and have a process in SQl Agents Jobs run periodically to pick the information up and send either way.

  • Our office loves using xp_sendmail for business flow notifications. An overview can be found at:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_xp_aa-sz_6hbg.asp



    Everett Wilson
    ewilson10@yahoo.com

  • I'd recommend doing it only for tables with low numbers of inserts, xp_sendmail isn't the quickest call in the world. Also have to decide what to do if multiple rows inserted in the transaction, whether to send one email or cursor through and process each separately.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply