Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 sqlcmd.exe - can strip out trailing spaces?

Author  Topic 

daluu
Starting Member

2 Posts

Posted - 2008-09-17 : 18:33:11
I'm using sqlcmd to log the query results into CSV format.

Unfortunately, there is some cleanup work involved to get a nice CSV file like deleting the "---" row that delimits the column header row from the data rows and removing the extra blank lines and "(x rows affected)" line at the end of the file

But I also notice the output is somewhat tab delimited, where extra trailing white spaces are inserted in the output to align the columns. Is there a way to not pad the results with trailing white spaces, etc.?

Here is the command I use:

sqlcmd -S LOCALHOST -E -i "script.sql" -o "output.csv" -s ","

I could do an XML query output instead but would prefer to keep my SQL select queries non-XML.

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-09-18 : 22:50:07
check out the -W switch.

http://msdn.microsoft.com/en-us/library/ms162773.aspx


elsasoft.org
Go to Top of Page

daluu
Starting Member

2 Posts

Posted - 2008-10-07 : 14:18:10
thanks. missed that option somehow.
Go to Top of Page
   

- Advertisement -