Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 Query to run SQL Query automatically @ 12.00am
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Yak Posting Veteran

58 Posts

Posted - 02/28/2013 :  04:57:25  Show Profile  Reply with Quote
I need to write a sql query which should run end of every month and send a excel report. Is this possible in scheduling??

here is the sample query:
DATENAME(day,bookDate) as day, DATENAME(Month,BookDate) as Month,
COUNT(Invoice) AS [Total Bookings],
cast (Sum(Negotiated) as decimal (22,2)) AS [Total Sale Price],introducer

FROM tblInvoice
WHERE BookDate >= '2001-01-01'
AND BookDate <= '2020-01-01'

GROUP BY DATENAME(Month,BookDate) , DATENAME(day,BookDate),introducer,
ORDER BY DATEPART(dd,BookDate),DATEPART(MM,BookDate),introducer

Thanks in Advance..


Very Important crosS Applying yaK Herder

52326 Posts

Posted - 02/28/2013 :  06:34:12  Show Profile  Reply with Quote
its possible. Create query, add it as a SQL Server agent job step and schedule job to execute every month once at last date.

SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000