sql server:我可以在金钱字段中插入$吗
我正在将“$5.99
”之类的值插入(或尝试插入)到 money
字段中。它不喜欢美元符号,
我实际上是从 csv 文件进行批量插入。 csv 文件中的一列中有 money
并带有美元符号,
您能帮我弄清楚如何将 $
符号批量插入 <代码>金钱字段?
Msg 4864, Level 16, State 1, Line 1
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 2 (pricepaid).
我该如何去掉这个标志?
i am inserting values like '$5.99
' (or trying to insert) into a money
field. it doesnt like the dollars sign
i am actually doing a bulk insert from a csv file. one of the columns in the csv file has money
in it with a dollar sign
can you please help me figure out how to do this bulk insert with the $
sign into a money
field?
Msg 4864, Level 16, State 1, Line 1
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 2 (pricepaid).
how do i get rid of the sign?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
基于这个问题以及您之前的问题此处和这里,我建议您将批量插入到临时保存表中,您可以在其中将“money”字段定义为 varchar。然后再编写一条SQL语句将数据从保持表移至真实表。在此 SQL 语句中,您可以跳过不需要的列,从“money”字段中删除“$”并将其转换为 Money 数据类型等。
Based on this question, as well as your earlier questions here and here, I'd recommend that you do your bulk insert into a temporary holding table, where you could define your "money" field as a varchar. Then write another SQL statement to move the data from the holding table to the real table. In this SQL statement, you could skip unwanted columns, remove the '$' from your "money" field and cast it as a money data type, etc.
不可以,您不能将货币符号插入货币字段。
它实际上只是一个带有友好名称的十进制(19,4)。
No, you can't insert currency symbols into a money field.
It's really just a decimal(19,4) with a friendly name.
作为解决方法,您可以创建一个与目标具有相同架构的表,使用 varchar 列而不是 Money,然后批量插入到该表中。然后更新导入的表以删除“$”并将数据复制到原始目标。
As a workaround, you could create a table with the same schema as your target, using a varchar column instead of money, and bulk insert into that. Then update the imported table to remove the '$' and copy the data to the original target.
你不能,Money 只是一种数字类型,灵活性比十进制稍差。要使用符号存储,您必须使用 varchar
you can't, Money is just a numeric type slightly less flexible than decimal. to store with the symbol you would have to use a varchar
其他人建议使用临时表。如果您使用临时表来保存 CSV 文件中的原始数据,您应该能够从
Varchar
或Char
直接转换为Money
> 包含 $ 字符的字段(即,不删除它)。这在 SQL 2008 中对我有用。
Others have suggested a temporary table. If you use a temp table to hold the raw data from your CSV file, you should be able to convert directly to
Money
from aVarchar
orChar
field containing a $ character (that is, without removing it).This worked for me in SQL 2008.