小编use*_*244的帖子

nvarchar值'3001822585'的转换溢出了一个int列

我使用以下将Excel文件导入SQL Server.

Excel文件的所有值都是字符串.我能够导入除了文件Barcode,SalePricePrice2.我收到错误

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)

sql type-conversion table-valued-parameters sql-update

5
推荐指数
1
解决办法
4万
查看次数