How to use TAB as column separator in SQLCMD

后端 未结 11 1262
后悔当初
后悔当初 2020-12-16 17:36

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 bo

11条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-16 18:22

    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
    

提交回复
热议问题