Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
alienation
Starting Member
4 Posts |
Posted - 2008-01-21 : 10:30:58
|
| Hey guys, I need a little help for my group project(Using ASP.NET 2 connected to SQL Server 2005). Here's the scenario:Our system is basically a sort of login/logout system, so we have a table that has (Name, Date, Subject, TimeIn, TimeOut).1. User registers on website, so information like e-mail is recorded into the database (and the user in the website is "linked/checked" to his data in the SQL Server for verification).2. Users can choose to subscribe to a weekly report e-mail(maybe using a simple "IsSubscribed" boolean value in the database).3. Every week, our system scans the database for those users who subscribed, then send different e-mail reports depending on the particular user (a compiled weekly report for Mon-Fri).Is there such a feature in Database Mail? If not, how do I execute these types queries and just set them as a Scheduled Task?Any help would be appreciated. |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-01-21 : 11:33:15
|
| Look up sp_send_dbmail in BOL. You can write a query to get the results you want for a particular set of users and then schedule this. |
 |
|
|
alienation
Starting Member
4 Posts |
Posted - 2008-01-21 : 12:04:52
|
| Thanks for the quick reply. I scanned msdn, and I have one more question about sp_send_dbmail.Will I have to manually modify the query code to adjust the date every week? Or does SQL have some sort of query that can "SELECT * from Current Date until (Current Date - 5 Days)"? |
 |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-01-21 : 14:57:46
|
| select * from table where date between dateadd(day, -5, getdate()) and getdate() and ... |
 |
|
|
|
|
|
|
|