BCP command

  • I used this command to export data out to text file with comma delimiter; however, it did not show the table field name for me.  Is there a way to go over it. Data looks good but I need field name as well.

    bcp pubs..publishers out publ_out /c /t , /r \n /Sservername

    /Usa /Ppassword

    Thanks in advance.

    Minh Vu

     

  • They don't have a switch for it so....

    bcp "SELECT 'Pub_ID','Pub_Name','City','State','Country' UNION ALL SELECT * FROM Pubs..Publishers" queryout publ_out /c /t , /r \n /Sservername /Uloginname /Ppassword

    You could do a trick or two with OSQL but it will have dashed lines in it so not a good idea...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • And this "Header" row will eventually end up at the end of the file or somwhere betwen the lines.

    _____________
    Code for TallyGenerator

  • Hasn't yet, Serqiy...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply