BCP is padding rows with H

  • Hi folks,

    I am trying to export a query to a text file using bcp. I wrote the query as fixed length per our customer's request and therefore used CRLF ( + CHAR(13) + CHAR(10)) to define the rows. It looks great when I manually export it in Management Studio, but when I send it via bcp it adds "H" when using the following script to test it...

    bcp "SELECT * FROM db.dbo.query" QUERYOUT test.text -n -S servername -T

    Which yields the following...

    HF21TXTFX210118

    When I use

    bcp "SELECT * FROM db.dbo.query" QUERYOUT test.text -c -S servername -T

    It adds spaces between the rows as shown below...

    F21TXTFX210118

    F21TXTFX210118

    F21TXTFX210118

    So, the format is wrong either way and I don't see the other rules defining the row structures. Any ideas as to how I can get the file to export with no spaces and no added characters to the text files?

  • Disregard!

    I figured it out.

    +CHAR(13) + CHAR(10) is not necessary when using bcp. I removed them from the script and ran the bcp with -c and it worked great.

    Thanks me! 😛 😎

  • Thank you for completing your question. That gives it some value for anyone who encounters a smimlar problem.

    This avoids having the forum polluted with dead questions when the author just says "I figured out myself" WITHOUT indicating how. These are just a waste of time for every body else.

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

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