Friday, February 10, 2012

Check sql table input at certian times and send email

I have a .net web application and need to create a program that needs to check the database every two hours and if data has not been input send the user an email message. I have heard this can be done via SQL Server - events or triggers? Can anyone tell me where I can find example code or more information on this. Thank you in advance.

Hi,

Yes since your whole work is within the database then I think setting up a "SQL job" will be the best possible solution also you can schedule it to run on certain times. Basically you need to create a "stored procedure" which will check the table and will be sending mail and you can call this stored procedure from your job. Mails can be sent by using "SQL Mail" or using .NET framework (if you are using Sql Server 2005).

I have marked the importent terms in the mail. You can get best materials on them in Books Online in Sql Server.

Hope it helps!

Bhaskar!

|||

In a well trafficed website, I usually drop that in the login.aspx page, or if I have enabled cookies, then another often hit page.

You can also do this using sql agent. Write the stored procedure to scan the table, and generate the emails. Then tell sql agent to execute that stored procedure every two hours.

No comments:

Post a Comment