|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I need to be able to send a reminder to my users who have not submitted data by a certain date,on the other hand need to be able to send data once gathered to a person analaysing it.
I have strongly been advised to write a procedure for an SQL server that would do that for me,except that I have never written a single procedure. And how would I once I hopefully write this procedure "link" it, make it work with my asp web pages?? I was hoping to see if somebody could help me with this,show me an example of a procedure they have created or something similar,any help is welcome. Regards |
|
#2
|
||||
|
||||
|
For the first part, you could create a stored procedure that would determine when the email needed to be sent, the stored procedure could then call a trigger to send the email.
Give more details and I'll see how much I can help you. |
|
#3
|
|||
|
|||
|
Thanks for that, I have written down the guideline of what I think is needed(logically).
1.Check the day of the month,if not the 5th then ignore/do nothing 2.Get the date of the previous month,i.e. Get the current date - 1 month,set day=1(not sure that will be able to explain this,it is just that they select the month and the year as DateEntered and that gets written as full date and defaults to the 1st of the month) 3.Get the list of hospitals that haven't got any data that relates to the previous month 4.Email a reminder to hospitals 5.Close off Hope this makes sense and you can help me, thanks in advance |
|
#4
|
||||
|
||||
|
If you are basing it on the current date, then you could do something like this.
Code:
DECLARE @returnDay int; DECLARE @prevMonth DateTime; SELECT @returnDay = DatePart(day,GetDate()) If @returnDay = 5 If it is the 5th of the month BEGIN SELECT @prevMonth = GetDate() - 30 Not sure how you are determining that a hospital has no data for the previous month. SELECT * FROM Hospitals WHERE DatePart(month, DateField) = DatePart(month, @prevMonth) Call your component to send the email END Last edited by Memnoch : April 20th, 2004 at 07:34 PM. |
|
#5
|
|||
|
|||
|
Thanks for your help
|
|
#6
|
|||
|
|||
|
Acctually something else I forgot to ask you once I have hopefully have this working the way I need it, how do you "call it" from asp pages, if you know what I mean?
|
|
#7
|
|||
|
|||
|
If @returnDay = 5
If it is the 5th of the month BEGIN SELECT @prevMonth = GetDate() - 30 If I run this code I always get Incorrect syntax near '5', I have tried putting the number in single comas but the same thing happens,do you know what is the problem here, and the same happens with the line where 30 is. |
|
#8
|
||||
|
||||
|
You are using SQL Server right?
What version of Sql Server? Those statements shouldn't cause any errors. |
|
#9
|
|||
|
|||
|
Yes SQL server,2000
an as for @prevMonth I am using my field DateEntered |
|
#10
|
|||
|
|||
|
Ingnore that, my mistake,syntax is fine now
|
|
#11
|
|||
|
|||
|
Am I not understanding this properly,or...
this line: "If @returnDay = 5 Begin Select @prevMonth = GetDate() - 30" What happens when a month has 31 days, of Feb 28 or 29 days? |
|
#12
|
||||
|
||||
|
Quote:
I just used 30 to calculate back 30 days. You can change it to what ever you need. |
|
#13
|
|||
|
|||
|
error
Last edited by zobernjik : April 22nd, 2004 at 10:11 PM. |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Write an email reminder/email scheduling procedure help? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|