简体   繁体   中英

Check SQL Server table every month

I need to check entries in a database every month to see if they have been updated. For example, an entry would look something like this:

id   timestamp     completed
123  12-AUG-2011      N

I need to check to see if the entries in this table have been 'completed' within 30 days of their timestamp. I then need to send an e-mail to specified person who can then handle the ageing entry.

Is there a way to achieve this using just C# (Visual Studio 2010) and SQL Server 2008? Scripts are disallowed on this particular server I am working with so I'm hoping there is an alternate solution.

Thanks.

It will depend on what version or configuration of SQL server your host has but you may be able to schedule jobs to run through SQL server agent.

Here's a HOWTO

You could create a very simple Windows Service to run at whichever time interval you require. So say every month it would tick and dispatch an event to perform the checking and email if needed and when finished set the interval again to the next month. This way you could expand easily enough at a later point.

If you've not done a service before then this article might be a nice start.

Hope that helps.

Paul

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM