Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old April 19th, 2004, 08:09 PM
zobernjik zobernjik is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Australia
Posts: 139 zobernjik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 31 m 10 sec
Reputation Power: 5
Unhappy Write an email reminder/email scheduling procedure help?

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

Reply With Quote
  #2  
Old April 19th, 2004, 08:55 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
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.

Reply With Quote
  #3  
Old April 19th, 2004, 09:45 PM
zobernjik zobernjik is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Australia
Posts: 139 zobernjik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 31 m 10 sec
Reputation Power: 5
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

Reply With Quote
  #4  
Old April 20th, 2004, 09:42 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
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.

Reply With Quote
  #5  
Old April 20th, 2004, 07:33 PM
zobernjik zobernjik is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Australia
Posts: 139 zobernjik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 31 m 10 sec
Reputation Power: 5
Thanks for your help

Reply With Quote
  #6  
Old April 20th, 2004, 07:35 PM
zobernjik zobernjik is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Australia
Posts: 139 zobernjik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 31 m 10 sec
Reputation Power: 5
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?

Reply With Quote
  #7  
Old April 21st, 2004, 09:45 PM
zobernjik zobernjik is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Australia
Posts: 139 zobernjik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 31 m 10 sec
Reputation Power: 5
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.

Reply With Quote
  #8  
Old April 21st, 2004, 10:35 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
You are using SQL Server right?
What version of Sql Server?

Those statements shouldn't cause any errors.

Reply With Quote
  #9  
Old April 21st, 2004, 11:00 PM
zobernjik zobernjik is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Australia
Posts: 139 zobernjik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 31 m 10 sec
Reputation Power: 5
Yes SQL server,2000

an as for @prevMonth I am using my field DateEntered

Reply With Quote
  #10  
Old April 21st, 2004, 11:09 PM
zobernjik zobernjik is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Australia
Posts: 139 zobernjik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 31 m 10 sec
Reputation Power: 5
Ingnore that, my mistake,syntax is fine now

Reply With Quote
  #11  
Old April 22nd, 2004, 12:16 AM
zobernjik zobernjik is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Australia
Posts: 139 zobernjik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 31 m 10 sec
Reputation Power: 5
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?

Reply With Quote
  #12  
Old April 22nd, 2004, 09:25 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
Quote:
Originally Posted by zobernjik
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?

I just used 30 to calculate back 30 days.
You can change it to what ever you need.

Reply With Quote
  #13  
Old April 22nd, 2004, 10:04 PM
zobernjik zobernjik is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Australia
Posts: 139 zobernjik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 31 m 10 sec
Reputation Power: 5
error

Last edited by zobernjik : April 22nd, 2004 at 10:11 PM.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Write an email reminder/email scheduling procedure help?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |