1

我正在尝试使用 BCP 将 csv 文件批量插入到 SQL 表中,但无法修复此错误:“第 1 行第 2 列的数据文件中的列太长。验证字段终止符和行终止符指定正确。” - 有人可以帮忙吗?

这是我的 SQL 代码:

BULK INSERT UKPostCodeStaging
FROM 'C:\Users\user\Desktop\Data\TestFileOf2Records.csv'
WITH (
DATAFILETYPE='char',
FIRSTROW = 1,
FORMATFILE = 'C:\Users\User\UKPostCodeStaging.fmt');

这是我在 TestFileOf2Records.csv 中包含的测试数据:

"HS1 2AA",10,14,93,"S923","","S814","","S1213","S132605"
"HS1 2AD",10,14,93,"S923","", "S814","","S1213","S132605"

这是我尝试适当编辑的 BCP 文件:

10.0
11
1   SQLCHAR  0  0  "\""      0  FIRST_QUOTE                 SQL_Latin1_General_CP1_CI_AS
2   SQLCHAR  8  0  "\","     1  PostCode                    SQL_Latin1_General_CP1_CI_AS
3   SQLINT   1  0  ","       2  PositionalQualityIndicator  ""
4   SQLINT   1  0  ","       3  MetresEastOfOrigin          ""
5   SQLINT   1  0  ",\""     4  MetresNorthOfOrigin         ""
6   SQLCHAR  8  0  "\",\""   5  CountryCode                 SQL_Latin1_General_CP1_CI_AS
7   SQLCHAR  8  0  "\",\""   6  NHSRegionalHACode           SQL_Latin1_General_CP1_CI_AS
8   SQLCHAR  8  0  "\",\""   7  NHSHACode                   SQL_Latin1_General_CP1_CI_AS
9   SQLCHAR  8  0  "\",\""   8  AdminCountyCode             SQL_Latin1_General_CP1_CI_AS
10  SQLCHAR  8  0  "\",\""   9  AdminDistrictCode           SQL_Latin1_General_CP1_CI_AS
11  SQLCHAR  8  0  "\"\r\n"  10 AdminWardCode               SQL_Latin1_General_CP1_CI_AS

有什么想法我哪里出错了吗?谢谢

4

0 回答 0