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????

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