How can i put the result of a sql server query into a "comma delimited" format?
A:
Check out this answer on the MySQL forums.
Here's the snippet.
SELECT a,b INTO OUTFILE '/tmp/result.text'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM test_table;
Ólafur Waage
2009-04-23 16:43:42
+1
A:
If you are using sql server managment studio right click on the output and you can "Save Result as" CSV
Aaron
2009-04-23 16:44:55
+3
A:
You should be able to go to Tools->Options->Query Results
in SQL Server Management Studio and set the preferences there to output to a text file.
Then expand that and in "Result to Text" you can set the output format there.
Ryan Smith
2009-04-23 16:47:23
A:
DECLARE @str VARCHAR(8000) SET @str = ''
SELECT @str = @str + column + ',' FROM table SELECT @str
JNappi
2009-07-10 02:32:03
Really useful if the data itself contains commas.
John Machin
2009-07-10 03:33:53