SQL Triggers

Results 1 to 2 of 2

Thread: SQL Triggers

  1. #1
    Chris W Guest

    Default SQL Triggers

    Anyone have a good resource on creating SQL Triggers? I&#039m trying to create one that will send out an email message through SQLMail when a new record is inserted into my table. I have SQLMail configured and working correctly to send e-mail within a Job on a database so that part is ready.

  2. #2
    Garth Guest

    Default RE: SQL Triggers

    A trigger is just a stored procedure that is *attached* to a table. The Books Online (BOL) covers them pretty well. If your email address is static then the trigger is very straitforward. Something like... <BR><BR>CREATE TRIGGER trg_TriggerName<BR>ON TableName<BR>FOR INSERT<BR>AS<BR>EXEC master..xp_sendmail &#039EmailAddress&#039,<BR> &#039message&#039<BR><BR>If the email address is dynamic then you have to SELECT it into a variable, build a string with xp_sendmail and then EXEC it.<BR><BR>Garth<BR>www.SQLBook.com<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts