SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 
        
Home       Members    Calendar    Who's On



Scripted job - run select and send results via XLS in an email Expand / Collapse
Author
Message
Posted Tuesday, November 11, 2008 9:05 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, June 01, 2009 12:11 PM
Points: 23, Visits: 49
I have a SELECT statement that I need to run on a weekly basis. I need the results to be put in CSV/XLS format and to be emailed automatically. Is there anyway to do this via a job?

Any help on this would be greatly appreciated.


Thanks,
Damon Jongbloed
Jennie-O Turkey Store, Inc.
Post #600740
Posted Thursday, November 13, 2008 10:18 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, June 29, 2009 9:06 AM
Points: 283, Visits: 360
There is but it's not a recommended approach as you need xp_cmdshell switched on etc. Also do you have Database mail activated? The best way is via SSIS, but you could also try the following;

http://www.sqlservercentral.com/Forums/Topic487837-19-1.aspx#bm492666
Post #602256
Posted Thursday, November 13, 2008 2:16 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, July 02, 2009 11:29 AM
Points: 316, Visits: 569
Use sp_send_dbmail. You can specify a query parameter to be attached as a file. You can also specify a header and a delimiter. So setup a query and specify comma as the delim with a header (or not). Name the file .csv and bingo you should have what you need.
Post #602395
Posted Thursday, November 13, 2008 2:25 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, June 25, 2009 2:14 PM
Points: 20, Visits: 114

Use OLE DB Source ( and put ur select statement in there) then have an excel destination . Then in the control flow- have a send mail task that follows the above “data flow task” and send the excel file as an attachment and finally schedule it to run using sql agent
Post #602402
« Prev Topic | Next Topic »


Permissions Expand / Collapse