Monday, March 19, 2012

Importing Errors when using BCP

Alright, I've been getting an interesting error when using BCP between two databases on the same MSSQL Server 2000. I am bulk copying data from an older version of a database into a newer one, which includes new tables and columns. When bcp gets to a certain table, I get this error

SQLState = 22005, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification

If anyone would happen to know exactly what SQL is executed by BCP or where to find such information, that would be great. None of the columns' data types have been changes in the newer version of the database.
-MikeYou migt try running profiler while using BCP but I don't think you will find much. The error seems to indicate a problem converting data.

Could you post the table structures, BCP command(s) and any BCP format files?|||DTS might give you more of a clue to where the actual error is.

I had a problem like this once that turned out to be typos in date fields that were before 1/1/1753 or whatever the magic "start date" in SQL server is (like '12/31/0999' instead of '12/31/1999').|||You should get a nice picture of the problem with the -o(filename) switch on BCP. The output file will just contain the rows that are causing the errors. I had a similar problem with "Right string truncation" errors in BCP, and the -o spotlighted the problem immediately.

No comments:

Post a Comment