问题
With the DB tool sqsh, I want to get the column names and the data tab delimited.
The bcp option does not include the column names.
The csv option includes the column names, but uses comma as the separate (doh). Is there a way to change it?
Currently looking to post-process the file to change the commas to tabs (ignoring the commas within strings...).
回答1:
You can \set colsep="\t"
to change the separator for the standard output to tab.
Edit: \t didn’t work (in my cygwin), so I used <CTRL-V><TAB>. That works:
[228] > \set colsep=" " -- Hit CTRL-V then <TAB> here.
[229] > select 'ABC' as STRING, 12 as INT;
STRING INT
------ -----------
ABC 12
(1 row affected)
回答2:
Please note that since sqsh version 2.5 it is now possible to assign control characters to some variables like colsep, linesep, bcp_colsep and bcp_rowsep. So the
\set colsep="\t"
should work now properly with sqsh-2.5.
来源:https://stackoverflow.com/questions/17314269/what-options-are-there-for-the-sqsh-style-csv-or-anyway-to-get-tab-delimited