Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sqlcmd question

Status
Not open for further replies.

takaoki

Programmer
Aug 28, 2008
39
ZA
Hi,

Can I use sqlcmd to output to a "comma" (not tab) delimited file? I don't see any options to do this...

Thanks

 
Ok, I figured out how to do the comma (-s, -W)

sqlcmd -S myServer -d myDB -s , -W -Q "SELECT Ticker [Ticker], DataValue [Eqy_out] FROM myTab WHERE AsOfDate <= 'Oct 2 2008 12:00AM' AND ValidToDate >= 'Oct 2 2008 12:00AM' AND Field = 'EQY_SH_OUT'" -o e:\tmp\myFile.csv

But the file looks like this:

Ticker,EQY_SH_OUT
------,----------
EVG CN,79.908730
FSY CN,77.085230

Which I don't want... how do I fix the header so that it doesn't put the comma between the column names and no dashed line?

Thanks

 
Have a look at the parameters on the microsoft site (usually a good place to start).....


I do not believe you can remove the dotted line, and why would you want to remove the commas from the header, because if you try to import it to anything (including Excel), it will not know how split the headers of the colums. If you are using SSIS or DTS to import, just set the option to "my file has a header record" and it will ignore the first line.

Cheers,

M.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top