Results 1 to 5 of 5

Thread: SQL Trigger

  1. #1
    Join Date
    Jan 2008
    Posts
    20

    Unanswered: SQL Trigger

    I have a basic trigger that send an e-mail when a record is inserted in a table
    based on a condition in another table.
    For Example if the letter A is inserted in a column on Table A and the condition is met in table B the trigger execute and works fine.
    However the problem is, when you try to insert again and the condition
    above is met again it gives an error because the letter A is already in the table. How can you change it to e-mail everytime the above condition is met. Thanks

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Seeing the table and trigger DDL usually helps...
    George
    Home | Blog

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Start here.

    -PatP

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by HendrikB
    I have a basic trigger that send an e-mail when a record is inserted in a table
    Also, I think most people would suggest this is not a good idea. You would not want the email sending to be wrapped up in the same transaction as the writing the row.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Absolutely NOT a good idea to have triggers sending out e-mails.
    Use the trigger to populate a table that holds a queue of messages to be sent, and then have a SQL Server job scheduled to e-mail messages from the queue.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

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