How to use TAB as column separator in SQLCMD

后端 未结 11 1246
后悔当初
后悔当初 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条回答
  •  遥遥无期
    2020-12-16 18:22

    tldr: use ALT+009 the ascii tab code for the separator character

    In the example, replace {ALTCHAR} with ALT+009 (hold the ALT key and enter the digits 009)

    sqlcmd -E -d tempdb -W -s "{ALTCHAR}" -o junk.txt -Q "select 1 c1,2 c2,3 c3"
    

    Edit junk.txt. Tabs will be between columns.

    For other command line options:

    sqlcmd -?
    

    Note: The shell converts the ALT char to ^I, but if you try the command by typing -s "^I", you won't get the same results.

提交回复
热议问题