在将SQL Server 2012的数据复制到Azure DB时,我有问题。在这里,我正在列出我所做的步骤。
-
创建
.dat
和.xml
格式文件如下:bcp.exe dbo.user_sayti out "c:\dbo.user_sayti.dat" -w -k -Slocalhost -dsource_db -Uuser -Ppwd
bcp.exe dbo.user_sayti format nul -f "c:\dbo.user_sayti.xml" -w -x -Slocalhost -dsource_db -Uuser -Ppwd
dbo.user_sayti.dat
dbo.user_sayti.xml -
试图以保持身份值的身份值将其复制到Azure DB:
bcp.exe dbo.user_sayti in "c:\dbo.user_sayti.dat" -E -f "c:\dbo.user_sayti.xml" -Sserver.database.windows.net -dtarget_db -Uuser -Ppwd
并有"
Invalid character value for cast specification
" 错误。
我不明白为什么,因为.dat
文件包含标识列id (PK, int, not NULL)
的值127
,并且值数量与行数匹配。 -
然后,我尝试了没有
<</p>-E
的同一命令,并且该过程成功完成(该特定表中唯一的一行,它出现在target_db
中,具有身份列值=1
)。
用-w
替换-f
参数(架构定义)解决了愚蠢的问题:)