Wednesday, January 29, 2014

BCP - Import Date into field type of Date fails

If you look at the error message, you may notice this:



Error = [Microsoft][*SQL Server Native Client 11.0*]Invalid character value for cast specification

That is, the error message does not come from SQL Server, but from ODBC which has different rules for converting date values. I think that by default, it only accepts YYYY-MM-DD and YYYYMMDD. It may work if you use the -R switch to BCP. This switch enforces interpretation according to the system locale (which may be different from your own regional settings).


When you test, make sure that you test with a date like 13/01/2014, so that you can see that the dates are interpreted the way you want to interpret them.





Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

No comments:

Post a Comment