July 16, 2014 at 2:01 pm
I have to supply a daily report. I have written the correct query in T-SQL. Is there a way to use SQL Server to supply a daily CSV file or Excel file with the results?
I'm trying to avoid using Crystal Reports 🙂
July 16, 2014 at 3:24 pm
http://msdn.microsoft.com/en-us/library/ms190307.aspx
Section B at the bottom will get you started if you want to create a job and schedule it.
The best thing to do is set up Reporting Services and learn the basics of that. It is extremely easy to set up and you can scale it out when needed.
July 16, 2014 at 3:43 pm
Another option is to use bcp to create the csv file or SSIS for any of the file options and possibly sending it via email.
SSRS seems overkill for this task, but could be worth it if you need better format.
July 16, 2014 at 11:03 pm
inevercheckthis2002 (7/16/2014)
I have to supply a daily report. I have written the correct query in T-SQL. Is there a way to use SQL Server to supply a daily CSV file or Excel file with the results?I'm trying to avoid using Crystal Reports 🙂
What will be done with this daily report? Does it get emailed to a group of people or do they dip a common file somewhere? And, since it's "just" a report, does it actually need to be in an Excel file or is that what's being used to just make things "pretty"?
--Jeff Moden
Change is inevitable... Change for the better is not.
July 17, 2014 at 6:08 am
Jeff Moden (7/16/2014)
What will be done with this daily report? Does it get emailed to a group of people or do they dip a common file somewhere? And, since it's "just" a report, does it actually need to be in an Excel file or is that what's being used to just make things "pretty"?
It will be emailed to a researcher. Excel is preferred, CSV would be acceptable.
July 17, 2014 at 11:29 am
Another option is to embed the SQL query into Excel. Your researcher, with the proper access and permissions to the SQL database, can then just refresh the spreadsheet when he needs it.
July 19, 2014 at 12:08 pm
July 24, 2014 at 9:54 am
Just another way to do this with Powershell:
Invoke-Sqlcmd -Query "SELECT * FROM your_table;" -ServerInstance yourserver -Database yourdatabase | export-csv your.csv
It can also be scheduled as you will any other task.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply