SQL Server trigger vs. stored procedure to receive data notification |
 |
EXPERT RESPONSE FROM: Roman Rehak

|
 |
|


|
| > |
QUESTION POSED ON: 06 October 2008
I am using SQL Server 2000, and I have a database field for warranty expiration dates. I would like to know 30 days in advance when an item is about to go out of warranty. How would I go about creating a trigger to inform me of this?
|
|
|
To continue reading for free, register below or login
To read more you must become a member of SearchSQLServer.com
');
// -->

A trigger would not work well in this example. A trigger executes when you perform an INSERT/UPDATE/SELECT command on a row or rows of data, and it is typically only used in relation to the data just updated. If the data is not updated, no trigger would fire, either. In your case, it seems that you need something like a notification, instead.
I would develop a stored procedure to return the count of items too close to the warranty expire date. In the query, I would use the DATEDIFF function to find out if there are any matching rows. Then, I would create a scheduled job and have an email sent to me if the count is greater than zero.
|
|
|

|
|
 |

 |
 |
Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and
answer pairs from more than 250 TechTarget industry experts.
|
 |
 |
 |
|
 |
 |
 |
|
 |
|
 |