BCP Import error “Invalid character value for cast specification”

左心房为你撑大大i 提交于 2019-12-12 12:37:36

问题


All I am using BCP for import export and getting "Invalid character value for cast specification" error for only 1(first row of export) row while trying to import back. Table Structure Col1 -- Numeric(19,0) Col2 -- NVARCHAR(400) Col3 -- NVARCHAR(400) I am using following commands

FOR Export

EXEC master..xp_cmdshell 'bcp "SELECT TOP 10 Col1, Col2, Col3 FROM Server.dbo.TableName" queryout C:\Data\File.dat -S Server -T -t"<EOFD>" -r"<EORD>" -w'

Same way I am generating a FORMAT file

EXEC master..xp_cmdshell 'BCP Server.dbo.TableName format nul -S Server -T -w -f "C:\Data\File.fmt" -t"<EOFD>" -r"<EORD>" '

Now when I try importing data back into SQL Server table I am getting error "Invalid character value for cast specification" Error logs shows me something like this

#@ Row 1, Column 1: Invalid character value for cast specification @#

?1000   Mytestdataunicoded  nothing

Now from where this ? added in starting of my column data is still unknown.

I am able to import successfully when trying importing with format file, also able to import successfully when using switch -c, but for some purposes we must use -w switch to do that.

来源:https://stackoverflow.com/questions/31339664/bcp-import-error-invalid-character-value-for-cast-specification

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