我使用MSSQL 2019,我希望通过以下方式将CSV文件插入自动生成的DB中:
如果手动选择varchar导入的所有列,则可以,但如果使用选择浮动数据类型,则会出现一个错误。
DB排序规则- Latin1_General_100_CI_AS_SC_UTF8
来自CSV文件的数据:
XXX;XXX;TBJ;A;33;4;1.4;6;3000;1206;3216-18;3.2;0.2;1.6;0.2:0.1;1.8;hre_tbj_dla;K
XXX;XXX;TBJ;A;33;4;1.4;6;3000;1206;3216-18;3.2;0.2;1.6;0.2:0.1;1.8;hre_tbj_dla;M
XXX;XXX;TBJ;A;3.3;6;0.5;6;8000;1206;3216-18;3.2;0.2;1.6;0.2:0.1;1.8;hre_tbj_dla;K
加载到MSSQL导入平面数据向导中的数据:
TITLE: Microsoft SQL Server Management Studio
------------------------------
Error inserting data into table. (Microsoft.SqlServer.Import.Wizard)
------------------------------
ADDITIONAL INFORMATION:
Error inserting data into table. (Microsoft.SqlServer.Prose.Import)
------------------------------
The given value of type String from the data source cannot be converted to type float of the specified target column. (System.Data)
------------------------------
Failed to convert parameter value from a String to a Double. (System.Data)
------------------------------
Input string was not in a correct format. (mscorlib)
------------------------------
BUTTONS:
OK
------------------------------
发布于 2020-07-30 05:01:47
我通过大容量插入尝试不同类型的加载数据。
示例:
BULK INSERT [dbo].[xxx]
FROM 'c:\Users\xxx\Documents\Work\xxx.csv'
WITH
(
FIRSTROW = 2,
FIELDTERMINATOR = ';', --CSV field delimiter
ROWTERMINATOR = '\n', --Use to shift the control to next row
ERRORFILE = 'c:\Users\xxx\Documents\Work\xxx_error.csv',
TABLOCK
);
一切都完美无缺。
https://stackoverflow.com/questions/63154347
复制相似问题