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?
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.