How Can I Create Notifications When a Trigger is Run

  • I am really new to working with SQL so bare with me.....I recently created a trigger on our SQL server that monitors the use of DDL against our production database.  Whenever anything is done the information populates a table with the DDL command that was run, the time it was run and the user and computer it ran from.  This is working just great but I want to set it up so that an email is sent out to an operator with this information as well.  I have no idea how to do this.  I know how to setup notifications in a job just by using the 'notifications' tab but scripting it is a whole new thing to me. 

     

    Anyone able to explain this in a way that even a noob would understand?

     

    Thanks


    New to the DBA world...thank you for your help!,

    IanR

  • here's teh puedocode that I currently use for something similar:

    add one more column to your tracking table, a flag or field to signify "NotificationSent' or something.

    now create a job that will send a notification for each row that NotificationSent = 0.

    have the job send an email, and if successful, set the NotificationSent =1.

    schedule the job to run every 5 minutes or so.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Triggers are not good but can't you create a trigger on the table for insert to send the info via db mail?

     

    MohammedU
    Microsoft SQL Server MVP

Viewing 3 posts - 1 through 2 (of 2 total)

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