question

rdavison avatar image
rdavison asked

Needing help outputing Sql report to .csv to network folder

I have a sql report that I have scheduled to run every day within the SQL 2008 R2 - SQL Service Agent. My problem is, I need the output for Sql report to automatically download as a comma delimited file to a folder on our local network. What is the easiest way for me to accomplish this?
sql-agentsql server 2008 r2
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

rdavison avatar image rdavison commented ·
Is there a sql command I could include in this report to make it output to .csv to a specified network folder?
0 Likes 0 ·

1 Answer

·
Shawn_Melton avatar image
Shawn_Melton answered
It depends on what you mean by "sql report" in your SQL Agent job. I take the assumption that is just T-SQL statements or a stored procedure call. You can use a variety of things to get to a CSV file from your SQL Agent job, quick Google search will bring up examples of any of these: 1. Use BCP command in T-SQL 2. Use sqlcmd job step and export it to CSV using sqlcmd command. 3. PowerShell step, use Invoke-Sqlcmd and pipe it to "Export-Csv" cmdlet.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.