我使用以下将Excel文件导入SQL Server.
Excel文件的所有值都是字符串.我能够导入除了文件Barcode,SalePrice和Price2.我收到错误
nvarchar值'3001822585'(条形码)的转换溢出了一个int列
码:
SqlCommand sqlcmd = new SqlCommand
(@"MERGE Inventory AS target
USING (SELECT
LocalSKU, ItemName, QOH, Price, Discontinued,Barcode, Integer2
,Integer3, SalePrice, SaleOn, Price2 FROM @source)
AS Source ON (Source.LocalSKU = target.LocalSKU)
WHEN MATCHED THEN
UPDATE
SET ItemName = source.ItemName,
Price = source.Price,
Discontinued = source.Discontinued,
Barcode = source.Barcode,
Integer2 = source.Integer2,
Integer3 = source.QOH,
SalePrice = source.SalePrice,
SaleOn = source.SaleOn,
Price2 = source.Price2;", sqlconn);
SqlParameter param;
param = sqlcmd.Parameters.AddWithValue("@source", dr);
param.SqlDbType …Run Code Online (Sandbox Code Playgroud)