943,660 Members | Top Members by Rank

Ad:
  • MS SQL Discussion Thread
  • Unsolved
  • Views: 12400
  • MS SQL RSS
Nov 15th, 2006
0

SQL trigger based on a true/false field value

Expand Post »
Hi,

I have an MS SQL 2000 database with a table that is used to store the header information on product returns. One of the fields in the table is a true/false field that indicates if the return has been processed (become a credit note).

Can anyone tell me how I could go about creating a trigger that would send an email notifying a specific user that this field has been updated from processed=false to processed=true.

To make your eyes bleed a little more, and provide a "why" to this question, when our finance guys process a return and issue a credit note, they then have to switch to their email client and send an email to the internal individual that initiated return process. This takes 11 seconds and leaves the finance guys exhausted. So they have asked if I can automate the process.

Any guidance would be appreciated.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
andy_mcdougall is offline Offline
1 posts
since Nov 2006
Nov 16th, 2006
1

Re: SQL trigger based on a true/false field value

I don't have my sql server readily available, but you could use the "create trigger" command, then use the logical tables "inserted" and "deleted" (which represent what is and what was, respectively) to determine if processed=false in deleted and processed=true in inserted (be sure to handle the case where you have multiple items updated -- even if for a future enhancement that you may not be thinking of). Then you can use xp_sendmail to send the mail -- provided you've got it correctly installed and configured... check books online (SQL Server help) for more info. They have sample code too.

hope this helps.. I just don't have sql server handy to write up a sample..

Hi,

I have an MS SQL 2000 database with a table that is used to store the header information on product returns. One of the fields in the table is a true/false field that indicates if the return has been processed (become a credit note).

Can anyone tell me how I could go about creating a trigger that would send an email notifying a specific user that this field has been updated from processed=false to processed=true.

To make your eyes bleed a little more, and provide a "why" to this question, when our finance guys process a return and issue a credit note, they then have to switch to their email client and send an email to the internal individual that initiated return process. This takes 11 seconds and leaves the finance guys exhausted. So they have asked if I can automate the process.

Any guidance would be appreciated.
MCP
Reputation Points: 14
Solved Threads: 3
Light Poster
MCP is offline Offline
44 posts
since Sep 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MS SQL Forum Timeline: Conditional Execution Autoexec macro
Next Thread in MS SQL Forum Timeline: Restoring the Master database





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC