How to save query result using T-SQL in a csv file in SSMS 2008? Needs to be done programmatically.
-
I specifically said using T-SQL. Programmatically. Which means not through the GUI.Tony_Henrich– Tony_Henrich2009-09-04 00:24:34 +00:00Commented Sep 4, 2009 at 0:24
-
"In SSMS" MS suggests Management Studio to me.u07ch– u07ch2009-09-04 07:08:47 +00:00Commented Sep 4, 2009 at 7:08
-
The query window in SSMSTony_Henrich– Tony_Henrich2009-09-04 19:31:45 +00:00Commented Sep 4, 2009 at 19:31
Add a comment
|
2 Answers
You could use System.Diagnostics.Process to run the SQLCMD or OSQL or BCP programs to dump out csv files.
2 Comments
u07ch
Agree BCP is simplest way; this is a good primer simple-talk.com/sql/database-administration/… If BCP isnt an option then a CLR function would let you do it too.
Tony_Henrich
osql and bcp can't be run from the query window as these are command line programs. sqlcmd could work if you have access to it.