Insert trigger to run an ASPX script passing record columns as parameters

  • Hello!

    I am using SQL Server 2012 and my database is set to 'SQL Server 2000 (80)' compatibility level.

    I have a table called "FORMS" and I need that an email be sent every time I get an INSERT in the table.

    The email should contains a couple record columns including the auto generated key (this is very important). I already have the ASPX script to send the email and I suppose that if this is possible it should be done using a trigger, right?

    Could anyone please help me with the details about how to do that?

    Thank you!

  • I would use db_mail instead.

  • Yan Kleber - Wednesday, September 19, 2018 7:20 AM

    Hello!

    I am using SQL Server 2012 and my database is set to 'SQL Server 2000 (80)' compatibility level.

    I have a table called "FORMS" and I need that an email be sent every time I get an INSERT in the table.

    The email should contains a couple record columns including the auto generated key (this is very important). I already have the ASPX script to send the email and I suppose that if this is possible it should be done using a trigger, right?

    Could anyone please help me with the details about how to do that?

    Thank you!

    Unless your INSERTs are relatively rare for the given table, you could easily seriously slow down those inserts and waste a lot of resources on the e-mails if you have a LOT of them.   Triggers are usually the worst way to do this.   Within what time frame s the information needed by the recipient?

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • This is not a good idea. It's a very bad use of a trigger.  

    I would create a "queue" table, and in the trigger, insert into that.  I would then create a separate process, a SQL Job will work, that reads the queue table every x number of minutes and sends the emails.

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • Thank you for the inputs, friends!

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

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