Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to produce an csv output file from stored procedure in SQL Server

Tags:

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?

like image 367
Al Phaba Avatar asked Apr 18 '13 09:04

Al Phaba


People also ask

How do I create a CSV file in SQL Server?

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.

How do you store output of a stored procedure in a SQL Server .text file?

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.


1 Answers

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.

like image 95
WowBow Avatar answered Sep 21 '22 15:09

WowBow