views:

36

answers:

1

SQLCMD supports the -s parameter to specify the column separator, but I couldn't figure how how to represent the tab (CHAR(9)) character. I have tried the following but both don't work:

sqlcmd -S ServerName -E -Q"select * from mytable" -s"\t" -o results.txt
sqlcmd -S ServerName -E -Q"select * from mytable" -s'\t' -o results.txt

Any ideas how to do this in SQLCMD?

A: 

It's difficult to get unformatted results from SQLCMD.

If you want to create a tab-delimited output file, BCP might be a better bet:

bcp "select * from mytable" queryout results.txt -S server -T -c
Ed Harper