locked
SQLCMD - Tab Delimiter? RRS feed

  • Question

  • I am currently using the following command to create an output file:
    sqlcmd -S DB1\DB_DB1 -i M:\queries\test.sql -o M:\output.csv -s"," -W

    This is creating a beautiful CSV file.  How can I create a tab delimited file?  I read somewhere that using -s"<TAB>" did the trick, but that didn't work for me.

    Any suggestions?
    Friday, May 29, 2009 3:52 PM

All replies

  • I just read the following post you may have been referencing and got it to work.  If you look closely, it says to place it in notepad, hit the tab key and then save it as a batch file.  I followed the exact instructions and it seems to work fine. However, this is kind of a weird way to have to do it.

    http://social.msdn.microsoft.com/forums/en-US/sqltools/thread/3b18fc32-b966-4de3-96a1-e237b07396f7/
    Ken Simmons
    http://columbusga.sqlpass.org
    Friday, May 29, 2009 4:47 PM
  • Hi Ken,

    It does work, however the output file is HUGE.  Maybe it's another issue...

    When I save the output from SSMS, the file is roughly 25MB...  when I use SQLCMD to output the file, it's roughly 130MB... what's up with that?  Any ideas?
    Friday, May 29, 2009 4:49 PM
  • Nevermind, I think I figured out the whole size thing...  human interface error.... :-)
    Friday, May 29, 2009 11:16 PM
  • Instead of SQLCMD, consider using BCP with the queryout parameter.  IMHO, BCP is better tool for this job.
     
    BCP "SELECT * FROM MyDatabase.dbo.Foo" queryout M:\output.tab /T /c

    --
    Hope this helps.
     
    Dan Guzman
    SQL Server MVP
    http://weblogs.sqlteam.com/dang /
    "Jay Mazz" wrote in message news:2c903108-b004-453 6-b6af-9162f7992475...
    I am currently using the following command to create an output file:
    sqlcmd -S DB1\DB_DB1 -i M:\queries\test.sql -o M:\output.csv -s"," -W

    This is creating a beautiful CSV file.  How can I create a tab delimited file?  I read somewhere that using -s"<TAB>" did the trick, but that didn't work for me.

    Any suggestions?
    Saturday, May 30, 2009 4:38 PM
  • Hi Jazz,

    I am also facing the file size problem. management studio gave me small file size but sqlcmd gives very big file size. why is that so, can share what you mean by human interface error?

    Friday, May 18, 2012 8:32 AM
  • check this link this may help you

    http://social.msdn.microsoft.com/forums/en-US/sqltools/thread/3b18fc32-b966-4de3-96a1-e237b07396f7/

    Saturday, May 19, 2012 10:23 AM