BCP IN Error = [Microsoft][SQL Server Native Client 10.0]Invalid date format

大城市里の小女人 提交于 2019-12-08 04:57:13

问题


I am trying to insert some values in a table through BCP-IN by executing batch file.But facing this issue-

Starting copy...
SQLState = 22008, NativeError = 0
Error = [Microsoft][SQL Server Native Client 10.0]Invalid date format
SQLState = 22008, NativeError = 0
Error = [Microsoft][SQL Server Native Client 10.0]Invalid date format
SQLState = 22008, NativeError = 0
Error = [Microsoft][SQL Server Native Client 10.0]Invalid date format
SQLState = 22005, NativeError = 0

The file thorugh which data getting inserted is like this-

Marcus, Tom 371332  11-1-09 0:00    720.04  25.2    108.01  0   43.2    

And the table in which data getting inserted having coloumn-

EFFECT_DATE2] [datetime2](3) NULL,

Any suggestion how to avoid this error?


回答1:


You may want to check the default language settings for the target database, as that is used to interpret dates i.e. DATEFORMAT.

A solution would be reformat the date into ISO Standard format (YYYYMMDD) in the data file.

Alternatives would be either reformat the date to match the DATEFORMAT of the target database or change the DATEFORMAT by changing the database's default language setting.

See https://support.microsoft.com/en-us/kb/173907

As noted in the KB, changing the server's regional setting in the Control Panel will not change how Sql Server interprets the dates.




回答2:


Try using SQLCHAR in format file instead of SQLDATETIME. Set data in datetime field into your local format and use -R key for bcp.exe run.



来源:https://stackoverflow.com/questions/15405052/bcp-in-error-microsoftsql-server-native-client-10-0invalid-date-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!