在SQL Server中插入十进制值时C#bulk insert失败 [英] C# bulk insert failing while inserting decimal values in SQL server

查看:79
本文介绍了在SQL Server中插入十进制值时C#bulk insert失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我在数据库表中批量插入CSV文件时遇到问题。



我尝试过:



我们尝试在较低的环境中更改整理。但它正在上传它。

解决方案

在专家交换中找到 BCP.exe (不知道你是否使用此或 BulkCopy 命令)

  - 您可以使用适当的替换创建视图,并且bcp 来自

创建视图v_products
选择
ProductID,
ProductName,
replace(convert(varchar,UnitPrice),' 。',< span class =code-string>' ,')UnitPrice
from Northwind.dbo.products





另一种选择可能是使用-R选项:

Quote:

-R

指定使用定义的区域格式将货币,日期和时间数据批量复制到SQL Server对于客户端计算机的区域设置。默认情况下,区域设置将被忽略。



此处提供更多信息: bcp Utility [ ^ ]


Hi All,

I am facing issue while bulk inserting CSV files in database tables.

What I have tried:

We tried changing the collate in lower environment. But it is uploading it properly.

解决方案

Found this on Experts Exchange for BCP.exe (don't know if you use this or the BulkCopy command)

-- You could create a view with the appropriate replacements and bcp from that

 create view v_products
 select 
 ProductID, 
 ProductName, 
 replace(convert(varchar,UnitPrice),'.',',') UnitPrice
 from Northwind.dbo.products



Another option might be to use the -R option:

Quote:

-R
Specifies that currency, date, and time data is bulk copied into SQL Server using the regional format defined for the locale setting of the client computer. By default, regional settings are ignored.


More information here: bcp Utility[^]


这篇关于在SQL Server中插入十进制值时C#bulk insert失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆