0

I have a user that needs a CSV from SQL Server once or twice each month. I have been running the query and then exporting the CSV to a network location manually, but I want to automate this so that they can pull the data on their own or have it scheduled to update the file every other week.

It has been a long time since providing a solution like this, and I am overthinking it, so I am looking for a suggestion on what would be the proper way to provide a file like this now.

I currently just have a database connection setup in Excel that will run the query when the user wants it, but this feels unprofessional to provide as a solution.

Thanks for any recommendations.

ArJe
  • 3
  • 1
  • 1
    You can use data export wizard to create an SSIS package and run it via a scheduled SQL Job. You can also run @david-browne-microsoft script via Scheduled Task. – Alex Dec 23 '21 at 00:44
  • 1
    SSRS........... – Dale K Dec 23 '21 at 01:31

1 Answers1

3

Use Powershell:

PS C:\Users\david> invoke-sqlcmd "select * from sys.objects" | export-csv -Path "c:\temp\data.csv"
David Browne - Microsoft
  • 80,331
  • 6
  • 39
  • 67
  • See this: https://stackoverflow.com/questions/5471080/how-can-i-schedule-a-job-to-run-a-sql-query-daily – ASH Dec 25 '21 at 01:25