2
bulk insert dbo.A
FROM 'd:\AData.csv'
WITH 
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)

将批量数据插入数据库,在查看可疑数据后,我遇到了一个无法解释的错误:

消息 4867,级别 16,状态 1,第 6
行第 1 行第 42 列 (FES) 的批量加载数据转换错误(溢出)。

列 FES 是tinyint,现在smallintd:\AData.csv在第 1 行第 42 列中包含一个2。这种类型的错误还有其他来源吗?

- -附加 - -

我不确定如何正确发布此内容。

创建表脚本

create table AcsBy320082010Hus(
serialnoId bigint,
RT char,
DIVISION tinyint,
PUMA int,
REGION tinyint,
ST tinyint,
ADJHSG int,
ADJINC int,
WGTP int,
NP tinyint,
TYPE tinyint,
ACR tinyint,
AGS tinyint,
BDS tinyint,
BLD tinyint,
BUS tinyint,
CONP smallint,
ELEP smallint,
FS smallint,
FULP int,
GASP int,
HFL tinyint,
INSP varchar(6),
KIT tinyint,
MHP int,
MRGI tinyint,
MRGP int,
MRGT tinyint,
MRGX tinyint,
PLM tinyint,
RMS tinyint,
RNTM tinyint,
RNTP int,
SMP int,
TEL tinyint,
TEN tinyint,
VACS tinyint,
VAL tinyint,
VEH tinyint,
WATP int,
YBL tinyint,
FES tinyint,
FINCP int,
FPARC tinyint,
GRNTP int,
GRPIP tinyint,
HHL tinyint,
HHT tinyint,
HINCP int,
HUGCL bit,
HUPAC tinyint,
HUPAOC tinyint,
HUPARC tinyint,
LNGI tinyint,
MV tinyint,
NOC tinyint,
NPF tinyint,
NPP bit,
NR bit,
NRC tinyint,
OCPIP tinyint,
PARTNER tinyint,
PSF bit,
R18 bit,
R60 tinyint,
R65 tinyint,
RESMODE tinyint,
SMOCP int,
SMX tinyint,
SRNT bit,
SVAL bit,
TAXP tinyint,
WIF tinyint,
WKEXREL tinyint,
WORKSTAT tinyint,
FACRP bit,
FAGSP bit,
FBDSP bit,
FBLDP bit,
FBUSP bit,
FCONP bit,
FELEP bit,
FFSP bit,
FFULP bit,
FGASP bit,
FHFLP bit,
FINSP bit,
FKITP bit,
FMHP bit,
FMRGIP bit,
FMRGP bit,
FMRGTP bit,
FMRGXP bit,
FMVYP bit,
FPLMP bit,
FRMSP bit,
FRNTMP bit,
FRNTP bit,
FSMP bit,
FSMXHP bit,
FSMXSP bit,
FTAXP bit,
FTELP bit,
FTENP bit,
FVACSP bit,
FVALP bit,
FVEHP bit,
FWATP bit,
FYBLP bit,
WGTP1 int,
WGTP2 int,
WGTP3 int,
WGTP4 int,
WGTP5 int,
WGTP6 int,
WGTP7 int,
WGTP8 int,
WGTP9 int,
WGTP10 int,
WGTP11 int,
WGTP12 int,
WGTP13 int,
WGTP14 int,
WGTP15 int,
WGTP16 int,
WGTP17 int,
WGTP18 int,
WGTP19 int,
WGTP20 int,
WGTP21 int,
WGTP22 int,
WGTP23 int,
WGTP24 int,
WGTP25 int,
WGTP26 int,
WGTP27 int,
WGTP28 int,
WGTP29 int,
WGTP30 int,
WGTP31 int,
WGTP32 int,
WGTP33 int,
WGTP34 int,
WGTP35 int,
WGTP36 int,
WGTP37 int,
WGTP38 int,
WGTP39 int,
WGTP40 int,
WGTP41 int,
WGTP42 int,
WGTP43 int,
WGTP44 int,
WGTP45 int,
WGTP46 int,
WGTP47 int,
WGTP48 int,
WGTP49 int,
WGTP50 int,
WGTP51 int,
WGTP52 int,
WGTP53 int,
WGTP54 int,
WGTP55 int,
WGTP56 int,
WGTP57 int,
WGTP58 int,
WGTP59 int,
WGTP60 int,
WGTP61 int,
WGTP62 int,
WGTP63 int,
WGTP64 int,
WGTP65 int,
WGTP66 int,
WGTP67 int,
WGTP68 int,
WGTP69 int,
WGTP70 int,
WGTP71 int,
WGTP72 int,
WGTP73 int,
WGTP74 int,
WGTP75 int,
WGTP76 int,
WGTP77 int,
WGTP78 int,
WGTP79 int,
WGTP80 int)

标题行

序列号,RT,DIVISION,PUMA,地区,ST,ADJHSG,ADJINC,WGTP,NP,TYPE,ACR,AGS,BATH,BDSP,BLD,BUS,CONP,ELEP,FS,FULP,GASP,HFL,INSP,MHP, MRGI,MRGP,MRGT,MRGX,REFR,RMSP,RNTM,RNTP,RWAT,SINK,SMP,STOV,TEL,TEN,TOIL,VACS,VALP,VEH,WATP,YBL,FES,FINCP,FPARC,GRNTP,GRPIP, HHL,HHT,HINCP,HUGCL,HUPAC,HUPAOC,HUPARC,KIT,LNGI,MULTG,MV,NOC,NPF,NPP,NR,NRC,OCPIP,PARTNER,PLM,PSF,R18,R60,R65,RESMODE,SMOCP, SMX,SRNT,SVAL,TAXP,WIF,WKEXREL,WORKSTAT,FACRP,FAGSP,FBAHP,FBDSP,FBLDP,FBUSP,FCONP,FELEP,FFSP,FFULP,FGASP,FHFLP,FINSP,FKITP,FMHP,FMRGIP,FMRGP,FMRGTP, FMRGXP,FMVP,FPLMP,FREFRP,FRMSP,FRNTMP,FRNTP,FRWATP,FSINKP,FSMP,FSMXHP,FSMXSP,FSTOVP,FTAXP,FTELP,FTENP,FTOALP,FVACSP,FVALP,FVEHP,FWATP,FYBLP,WGTP1,WGTP2,WGTP3, WGTP4,WGTP5,WGTP6,WGTP7,WGTP8,WGTP9,WGTP10,WGTP11,WGTP12,WGTP13,WGTP14,WGTP15,WGTP16,WGTP17,WGTP18,WGTP19,WGTP20,WGTP21,WGTP22,WGTP23,WGTP24,WGTP25,WGTP26,WGTP27,WGTP28, WGTP29,WGTP30,WGTP31,WGTP32,WGTP33,WGTP34,WGTP35,WGTP36,WGTP37,WGTP38,WGTP39,WGTP40,WGTP41,WGTP42,WGTP43,WGTP44,WGTP45,WGTP46,WGTP47,WGTP48,WGTP49,WGTP50,WGTP51,WGTP52,WGTP53,WGTP54, WGTP55,WGTP56,WGTP57,WGTP58,WGTP59,WGTP60,WGTP61,WGTP62,WGTP63,WGTP64,WGTP65,WGTP66,WGTP67,WGTP68,WGTP69,WGTP70,WGTP71,WGTP72,WGTP73,WGTP74,WGTP75,WGTP76,WGTP77,WGTP78,WGTP79, WGTP80

第 1 行

2008000000023,H,6,01300,3,01,1012650,1031272,00043,04,1,1,,1,02,02,2,0000,150,2,0002,020,3,00150,,2, 00980,1,1,1,03,,,1,1,,1,1,1,1,,0210000,2,0080,09,2,000058100,2,,,4,1,000058100,0, 3,3,3,1,1,1,3,02,04,0,0,02,024,0,1,0,1,0,0,1,01170,3,0,1,19,1, 3,3,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,00112,00045,00068,00017,00044,00091,00071,00032, 00036,00042,00048,00041,00013,00048,00063,00013,0003,00017,00063,00098,00026,00036,00017,00065,00036,00020,000,00014,00035,00037,00046,00047,00048,000808048,0008080 00034,00012,00061,00031,00069,00043,00060,00011,000,0001,0005.1,00050,0001,0001,000.68,00056,0003,00042,00049,00081,00041,0001,0001,00092,00050,000555, 00049,00016,00062,00041,00103,00012,00048,00060,00073,00052,00063,00038,00047,00040,00017,00040,00059,00020,00042,00010,00038,

链接到 ACS 2008-2010 数据字典

4

1 回答 1

4

问题是您正在使用的数据类型。tinyint只能处理从 0 到 255 的整数数据。0210000不在该范围内。

我可以建议创建一个临时表,将这个文件转储到其中并使用所有(n)varchars 创建它吗?这样,您可以保留前导0s,这可能是您分析的数据类型所必需的。

从临时表中,您可以将清理操作运行到“报告”结构中,这将允许您使用更合适的数据类型,您可以通过 SQL 查询来识别这些数据类型来分析您的数据。

于 2012-11-06T21:43:06.680 回答