Solved

Run stored procedure in a trigger (I think)

Posted on 2008-06-18
5
823 Views
Last Modified: 2009-07-29
I have a table which hold records that represent invitations to answer questions in a survey. When the record is created it creates an email and sends it out using ASP. The recepient has 14 days to complete the survey then the invite no longer works. In the record is a column for date created.

What I want is a reminder email to be sent out after 7 days, then with 3 days left, and then 1 day left. I am assuming I would do this with a trigger and the stored procedure "msdb.dbo.sp_send_dbmail". Can anybody get me started in the right direction. Is a trigger the right direction? I might need some serious hand holding on this.
0
Comment
Question by:phishyman2
  • 3
  • 2
5 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 21816244
You can schedule a jon to do this, thats the best thing ..
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 21816246
I meant, a sql Job
0
 

Author Comment

by:phishyman2
ID: 21816381
OK.

I am assuming that during the creation of this job for the first step I would set it up as Transact-SQL script. Could you give me started on what I would put in the command box, based on the situation I listed above.
0
 

Author Comment

by:phishyman2
ID: 21816570
I understand that I want to call my stored procedure like this:

EXEC msdb.dbo.sp_send_dbmail @recipients='mak_999@yahoo.com',
    @subject = 'My Mail Test',
    @body = 'This is my mail test',
    @body_format = 'HTML' ;

But I only want to effect records returned by this query:

select * from franr.riskassessment
where date_created + 7 = getdate()

How do I combine them together?
0
 

Accepted Solution

by:
phishyman2 earned 0 total points
ID: 22521654
This issue has been resolved by another outside source that was beyond my control.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question