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.
CodePudding user response:
Use Powershell:
PS C:\Users\david> invoke-sqlcmd "select * from sys.objects" | export-csv -Path "c:\temp\data.csv"