BCP Utility

  • Please help!

    We are using BCP utility to create flat, comma delimited text files. Data is being read from MS SQL server tables and saved in the file on the network. Sometimes we are getting corrupted files with non-readable characters. Does anyone know why this could occur?

    FYI Data in the database tables is migrated from FORTRAN files.

    Thanks for your help,

    Ella

  • Ella

    How are you migrating the data from FORTRAN?  Were these files checked for errors?

     

  • These files are loaded into MS SQL tables. All fields in these tables are varchar.

  • Ella

    What I am trying to find out is whether you have checked the data in SQL Server, if its not corrupt when coming over from FORTRAN.

     

  • Information in the table looks OK. We did some additional investigation and found out that data in corrupted fields is represented as 00 in HEX format. We expected to see this data as Hex 20 because we thought that we have single spaces there. We still don't understand how this could have happened.

     

  • Hex00 is BCP's way of storing a blank string. It does this because it uses an empty field for Null.

    (It could be argued that it would have been more logical if BCP would use a special character for Null and an empty field should be an empty string, but BCP just doesnt do that)

    If you turn your empty strings into nulls you might get what you want - something like:

    BCP "Select Nullif(col1,''), ..." queryout ...

Viewing 6 posts - 1 through 5 (of 5 total)

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