下面是用于执行插入的 SQL 代码。
use Acs_DataStocks
BULK
INSERT [dbo].[AcsBy520072011Pus]
FROM 'D:\temp\ACS\ss11pusd_fixed.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n',
KEEPNULLS
)
GO
SQL Server Management Studio 中报告的错误是:
消息 4866,级别 16,状态 1,第 32 行批量加载失败。数据文件中第 3649556 行第 156 列的列太长。验证是否正确指定了字段终止符和行终止符。
消息 7399,级别 16,状态 1,第 32 行链接服务器“(null)”的 OLE DB 提供程序“BULK”报告了错误。提供商没有提供有关该错误的任何信息。
消息 7330,级别 16,状态 2,第 32 行无法从链接服务器“(null)”的 OLE DB 提供程序“BULK”中获取行。
以下是违规数据集中的第 3649556 行:
2010000576537,P,01,02004,55,1039407,00021,56,1,1,,,2,,,000000,,,11,2,3,1,5,,,,,,,,,,,, ,3,5,3,3,3,000000,00000,00,000000,1,,11,000000,2,00000,00000,020400,40,1,1,,2,142,032,,,,1,01, ,,,,,4,1,,0,4,000020400,000020400,055,228,02000,055,1,1,01,69,0,0,0,0,1,0,1,0,,, ,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00022,00007,00037,00037,00022 ,00021,00024,00006,00024,00024,00020,00039,0039,00007,00021,00007,00024,00022222222222222221,00021,006,00021,006,00038,00020,00020,00020,00023,0023,00005,0002,0002,0002,0002,00037 ,00021,00035,00036,00006,00020,00006,000221,0021,00006,00021,00021,0021,006,00038,00034,00034,00022,00022,000221,006,00024,00024,00024,00024,00020,00020,00020,00035,00037,00007,00020 ,00007,00021,00023,00006,0002222222222,006,00036,00039,00021,00022,000202,000202,000202,0002,00019,00019,00036,00025,00025,00038,00038,007,007,007,006,00021,00021,00023,00006,00021 ,NA,NA////,NA,NA//,3500,292061,8170,6216
显示的数据字段的值为 "00024" 。该表仅使用 varchar(50) 字段创建。这个错误是可重现的,但没有解释。为什么是这样?