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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQLCMD

Status
Not open for further replies.

Cobby1812

IS-IT--Management
Jun 22, 2006
58
GB
Morning,

I am using a SQLCMD to export data from one view into a CSV file.

If I do this on screen running the actual query then highlight the results and save as Export File CSV then the size of the file is say 4mb. If I run from the SQLCMD it about 200mb.......I cant work out why...any idea's anyone.
 
Hi,

In this instance i would compare the files and find the difference first and foremost.

To do that i would use an app like WinMerge (i believe it is free) to compare the two files and find the difference. That may then get you closer to the why?

Dan

----------------------------------------

Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Bernard Baruch

Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
 
When on SSMS you select export as CSV SSMS will remove any trailing spaces and add the delimiter.
sqlcmd does not do this so you most likely have all fields being exported as fixed width with all the trailing spaces.

one option is for you to build your query converting all numbers/dates to strings, trimming all trailing spaces and adding the separator yourself.

Other option would be to use a powershell script to execute the query and export as CSV

Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
Thank y for the quic replies...will have a look and see what I can do.

Many thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top