gpt4 book ai didi

sql-server - SQL Server : The bulk load failed. 数据文件中第 1 行第 1 列的列太长

转载 作者:行者123 更新时间:2023-12-02 01:51:12 25 4
gpt4 key购买 nike

请有人帮助我。我已经看了几个小时了,但没有任何结果。

我使用以下脚本在 SQL Express 2008 R2 中创建了一个表:

CREATE TABLE Features
(
ID int not null identity(1,1 ),
StopID varchar(10),
Code int,
Name varchar(100),
Summary varchar(200),
Lat real,
Lon real,
street varchar(100),
city varchar(50),
region varchar(50),
postcode varchar(10),
country varchar(20),
zone_id varchar(20),
the_geom geography


CONSTRAINT [PK_Features] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

然后,我使用 bcp 工具针对我的数据库表创建了以下格式文件:

10.0
12
1 SQLCHAR 2 100 "," 2 StopID Latin1_General_CI_AS
2 SQLINT 1 4 "," 3 Code ""
3 SQLCHAR 2 100 "," 4 Name Latin1_General_CI_AS
4 SQLCHAR 2 200 "," 5 Summary Latin1_General_CI_AS
5 SQLFLT4 1 4 "," 6 Lat ""
6 SQLFLT4 1 4 "," 7 Lon ""
7 SQLCHAR 2 100 "," 8 street Latin1_General_CI_AS
8 SQLCHAR 2 50 "," 9 city Latin1_General_CI_AS
9 SQLCHAR 2 50 "," 10 region Latin1_General_CI_AS
10 SQLCHAR 2 10 "," 11 postcode Latin1_General_CI_AS
11 SQLCHAR 2 20 "," 12 country Latin1_General_CI_AS
12 SQLCHAR 2 20 "\r\n" 13 zone_id Latin1_General_CI_AS

此文件已被修改以删除 ID 和 the_geom 字段,因为这些字段不在我的数据文件中。

然后我尝试批量插入包含以下内容的 1 行 csv:

a,8,S,,45.439869,-75.695839,,,,,,

我得到的一切:

Msg 4866, Level 16, State 7, Line 35
The bulk load failed. The column is too long in the data file for row 1, column 1. Verify that the field terminator and row terminator are specified correctly.
Msg 7399, Level 16, State 1, Line 35
The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7330, Level 16, State 2, Line 35
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".

任何指示都会有所帮助,因为我无法弄清楚这一点。

最佳答案

问题是由我的格式文件中的默认前缀长度设置引起的。我导入的数据文件不是使用 bcp 创建的,因此我必须将所有字段的前缀长度设置为 0,如下所示:

0.0
12
1 SQLCHAR 0 100 "," 2 StopID Latin1_General_CI_AS
2 SQLINT 0 4 "," 3 Code ""
3 SQLCHAR 0 100 "," 4 Name Latin1_General_CI_AS
4 SQLCHAR 0 200 "," 5 Summary Latin1_General_CI_AS
5 SQLFLT4 0 4 "," 6 Lat ""
6 SQLFLT4 0 4 "," 7 Lon ""
7 SQLCHAR 0 100 "," 8 street Latin1_General_CI_AS
8 SQLCHAR 0 50 "," 9 city Latin1_General_CI_AS
9 SQLCHAR 0 50 "," 10 region Latin1_General_CI_AS
10 SQLCHAR 0 10 "," 11 postcode Latin1_General_CI_AS
11 SQLCHAR 0 20 "," 12 country Latin1_General_CI_AS
12 SQLCHAR 0 20 "\r\n" 13 zone_id Latin1_General_CI_AS

完成此更改后,导入成功。

关于sql-server - SQL Server : The bulk load failed. 数据文件中第 1 行第 1 列的列太长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8513943/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com