Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting a schedule

Status
Not open for further replies.

Cullen411

Programmer
Aug 17, 2005
89
GB
Is there a way to schedule SQL server to send an email.

For instance if I had a smalldatetime column and wanted to send an email to all customers whose subscription was over a year from the value in the smalldatetime could this be done?
 
create a job (schedule it daily) that will check the table and send out an email
use xp_sendmail

“I sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" --
 
One way is to have a daily DTS task that select all records from that table where the field value + 1 year is equal to system date.

The resulting recordset could then be used to send an email to each recipient.

You would need to cater for situations where the SQL server was down for one or more days. (e.g. set another table with "sent emails" and check if a particular ID has already been sent.

This is just an idea. If you search for email on this forum you will find some thread on how to email stuff. For more information regarding DTS you can also search the forums, but also search your copy of Books Online and will also be of great use.


Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top