问题
Is there any way to stop isql
from adding spacing before and after the returned fields? I just want the values from the table row separated by ,
. At the moment, using -b
and -s ','
, I get:
,some_column_entry , 3213, another_column_entry,
however, I want:
,some_column_entry,3212,another_column_entry,
I read through all the switches, but couldn't seem to find anything appropriate. My wish is to get isql
to output in this form rather than parsing the output.
EDIT:
select top 1 rtrim(ltrim(some_column)) from table
returns
,abc ,
isql
seems to output based on the size of max characters, because if I run the following:
select top 1 rtrim(ltrim(convert(varchar(3), some_column)) from table
I get:
,abc,
回答1:
Try this
Use RTRIM(LTRIM(ColumnName)) in your -q Query Select command.
回答2:
The contrast between
some_column_entry ,
and
, another_column_entry,
leads me to think that the spaces are part of your field entries, as opposed to the delimiters used.
From man isql
:
-dx Delimit columns with x.
-x0xXX Delimit columns with XX, where XX is in hex. For example -x0x09 will use a tab.
If that doesn't work, then you can pipe the output of isql
through a simple sed
use case:
isql ... | sed -e 's/\ //g'
来源:https://stackoverflow.com/questions/14064433/remove-white-space-from-isql-output