Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use TAB as column separator in SQLCMD

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?

like image 279
dawntrader Avatar asked Sep 30 '10 10:09

dawntrader


1 Answers

In a batch file, putting a tab between the double quotes works.

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

to do the same in a PowerShell file use escaped double quotes wrapped around an escaped tab

sqlcmd -S ServerName -E -Q"select * from mytable" -s `"`t`" -o results.txt
like image 200
Doogie Avatar answered Nov 16 '22 02:11

Doogie