将多行文件导入Azure SQL数据仓库时BCP错误数值超出范围

将多行文件导入Azure SQL数据仓库时BCP错误数值超出范围,azure,azure-sql-database,data-warehouse,bcp,azure-sqldw,Azure,Azure Sql Database,Data Warehouse,Bcp,Azure Sqldw,我正在尝试使用bcp实用程序加载Azure SQL数据仓库,但遇到了一个又一个问题…我最终获得了一个.txt文件,其中有一条记录要成功导入,但现在当我将两条或多条记录放入该文件时,它因错误(通过错误输出文件)而崩溃: 第1行第5列:数值超出范围 数据如下所示: 2014-06-01,11111,test,used,1 2014-06-01,22222,test,used,1 [Date] (date, not null) [Code] (varchar(50), not null) [Mode

我正在尝试使用bcp实用程序加载Azure SQL数据仓库,但遇到了一个又一个问题…我最终获得了一个.txt文件,其中有一条记录要成功导入,但现在当我将两条或多条记录放入该文件时,它因错误(通过错误输出文件)而崩溃:

第1行第5列:数值超出范围

数据如下所示:

2014-06-01,11111,test,used,1
2014-06-01,22222,test,used,1
[Date] (date, not null)
[Code] (varchar(50), not null)
[Model] (varchar(100), not null)
[Type] (varchar(20), not null)
[Quantity] (int, not null)
我要导入到的表如下所示:

2014-06-01,11111,test,used,1
2014-06-01,22222,test,used,1
[Date] (date, not null)
[Code] (varchar(50), not null)
[Model] (varchar(100), not null)
[Type] (varchar(20), not null)
[Quantity] (int, not null)
我认为这与新行的角色有关,但我一直无法解决这个问题。我已经尝试将Notepad++中的编码更改为ANSI、ISO-8859-1、UTF-8 w/o BOM,以及使用Visual Studio代码的UTF-16 LE&BE。指定“ANSI”后,单行文件导入成功。行尾序列设置为LF,我的bcp命令如下:

bcp Schema.Table in C:\BcpFiles\sourceData.txt -S serverName -d databaseName -U userName -P password -q -c -t "," -r/n -e C:\BcpFiles\Errors.txt

-r参数需要反斜杠而不是正斜杠:请改用-r\n。本文解释了各种组合:

更新:

create table tst (
[Date] date not null,
[Code] varchar(50) not null,
[Model] varchar(100) not null,
[Type] varchar(20) not null,
[Quantity] int not null
)
然后用这个:

bcp dbo.tst in so.txt-S TONYMSI-d AdventureWorks2012-T-q-c-T“,”-r\n


很好。

谢谢您的回复。然而,这并没有解决我的问题。它仍然适用于一条记录,但当我添加换行符(LF)时,错误是:“强制转换规范的字符值无效”,并且仍然指向第5列(数字1插入到INT列中)。你能看看我答案的更新吗?对我来说很好。这就引出了一个问题-您能否编写出您试图将BCP转换到的表,即-d指定的数据库中的表,还请注意-r和\n之间有一个空格,因为SQL数据仓库仅支持带UTF-8的BCP。重新尝试时,文件是否为UTF-8格式?