Is it possible to generate a csv file from a stored procedure in SQL Server? I created my stored procedure and I want to stored some result as csv, does someone know how to achieve this?
Open SQL Server Management Studio and connect to the database. 2. Go to "Object Explorer", find the server database you want to export in CSV. Right-click on it and choose "Tasks" > "Export Data" to export table data in CSV.
A stored procedure to write-out the data With this Stored procedure you can write directly from SQL to a text file. @Text VARCHAR(8000) What you want written to the output file. @File VARCHAR(255) Path and file name to which you wish to write.
I think it is possible to use bcp command. I am also new to this command but I followed this link and it worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With