SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

anuraag205
Yak Posting Veteran

India
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:
====================================================================
SELECT
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,
DATEPART(MM,BookDate),DATEPART(dd,BookDate)
ORDER BY DATEPART(dd,BookDate),DATEPART(MM,BookDate),introducer
+============================================================

Thanks in Advance..





Thanks

visakh16
Very Important crosS Applying yaK Herder

India
52309 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
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.05 seconds. Powered By: Snitz Forums 2000