Remove white space from isql output

bqui56 picture bqui56 · Dec 28, 2012 · Viewed 8.4k times · Source

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,

Answer

zaggler picture zaggler · Dec 28, 2012

Try this

    Use RTRIM(LTRIM(ColumnName)) in your -q Query Select command.