Tuesday, September 10, 2013

bulk insert loads my data, but my code crashes when trying to read or compare a text value

The issue was we would do a regular export from SQL Server of a table with an ID field and a varchar field. The export went fine. Then we did an import using bulk insert... the rowterminator was \n. Everything loaded fine. The issue arose when we ran code that compared values in the text field. The result caused a crash because it couldn't return an exact match.

The end result was we changed the rowterminator to another character. For some reason, we were getting phantom characters in the text field. We couldn't see them in the database or in the code. But, if we went into the database and retyped the value, it worked.

Best

No comments: