|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi guys,this is what I have created so far for my procedure that is suppose to email data to a person on every 7th of the month.
The syntax seems to be correct,so on the 7th it is running this query and then I need to create an excel file and email that as an attachment to a person. Could somebody have a look and help me please.How can I get the procedure to collect the data and create an excel file and email it???? CREATE PROCEDURE GetData AS DECLARE @RecipientID int DECLARE @SentToEmail varchar(50) DECLARE @returnDay int --Looking at current date, SELECT @returnDay = DatePart(day,GetDate()) If @returnDay = 7 SELECT a.HospitalName,a.HospitalCode,c.ProductName,b.Unit sDiscarded,b.DateEntered,b.DateCompleted,b.Compile dBy FROM Units b inner join Hospitals a ON (a.HospitalID = b.HospitalID) inner join Products c ON (b.ProductID = c.ProductID) order by a.HospitalID GO |
|
#2
|
|||
|
|||
|
These links may help:
Exporting to EXCEL: http://www.mssqlcity.com/Scripts/scrImpExp.htm Emailing in MS SQL: http://www.pstruh.cz/tips/detpg_sqlemailcdo.htm Good luck. |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Stored Procedure Help?? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|