SQL Server Performance

[Solved]Getting column header in a bcp file

Discussion in 'SQL Server 2005 General Developer Questions' started by Dale L, Jun 15, 2007.

  1. Dale L New Member

    Hello all

    Like the title says, im trying to bring the columns header in an exported file using the BCP command.

    Is there a way to do it?


    (I found a way trough the concatenation of all the data of the fields in a row into a long string but it would not work well because im using a query to get the informations i want to extract and it would be too complicated.)
  2. satya Moderator

    Seehttp://simple-talk.com/sql/database-administration/creating-csv-files-using-bcp-and-stored-procedures/ nigel's tip here.

    Satya SKJ
    Microsoft SQL Server MVP
    Writer, Contributing Editor & Moderator
    http://www.SQL-Server-Performance.Com
    This posting is provided AS IS with no rights for the sake of knowledge sharing. Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it.
  3. MohammedU New Member

    Is there any reason to add column headers into a bcp file?
    If you want to give some one to a query output file with header then you can use OSQL with h option...
    Check osql utility in bol...



    MohammedU.
    Moderator
    SQL-Server-Performance.com

    All postings are provided “AS IS” with no warranties for accuracy.
  4. Dale L New Member

    Isnt SQLCMD a better choice then?

    It says that osql is going to disappear in later version of SQL Server.
  5. satya Moderator

    Any luck with Nigel's script on the link above?
    Yes it is already, BOL confirms:
    This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use the feature. Use sqlcmd instead. For more information, see sqlcmd Utility.

    Satya SKJ
    Microsoft SQL Server MVP
    Writer, Contributing Editor & Moderator
    http://www.SQL-Server-Performance.Com
    This posting is provided AS IS with no rights for the sake of knowledge sharing. Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it.
  6. Dale L New Member

    I looked at nigel's script but running it or something similar would be too long and complicated because i have have too much different data.

    I think i will use the SQLCMD command. Its fast, easy and do exactly what i want to do.

    Thanks for the answers.


    Ho, i have a small question. What does BOL mean? The online help?
  7. MohammedU New Member

    Yes...OSQL is depricated... SQLCMD is replacing OSQL...
    So you can use SQLCMD instead of OSQL...


    MohammedU.
    Moderator
    SQL-Server-Performance.com

    All postings are provided “AS IS” with no warranties for accuracy.
  8. satya Moderator

    BOL [<img src='/community/emoticons/emotion-1.gif' alt=':)' />], yes it is shortform for Books OnLine and you will see this acronym in many SQL newsgroups.<br /><br /><b>Satya SKJ</b><br />Microsoft SQL Server MVP<br />Writer, Contributing Editor & Moderator<br /<a target="_blank" href=http://www.SQL-Server-Performance.Com>http://www.SQL-Server-Performance.Com</a><br /><center><font color="teal"><font size="1">This posting is provided AS IS with no rights for the sake of <i>knowledge sharing. <hr noshade size="1">Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it.</i></font id="size1"></font id="teal"></center>

Share This Page