[英]Error converting data type nvarchar to numeric SQL
Run time error : 运行时错误:
Error converting data type nvarchar to numeric 将数据类型nvarchar转换为数值时出错
Query : 查询:
SELECT ISNULL(a.[BPOFmv], 0) AS BPOFmv FROM [MyTables] as a
Records of a.[BPOFmv]
column as shown below. a.[BPOFmv]
列的记录如下所示。
$125,000
$145,000
209000
63,000
Question : 题 :
I think the issue here is $
mark.Can you tell me how to remove it ? 我认为这里的问题是$
mark。您能告诉我如何删除它吗? I'm going to insert these values into decimal(18, 2)
column. 我将这些值插入decimal(18, 2)
列。
You can use the REPLACE function 您可以使用REPLACE功能
SELECT ISNULL(REPLACE(REPLACE(a.[BPOFmv], '$',''),',',''), 0) AS BPOFmv
FROM [MyTables]
You can CAST it into a format too if you wish 您也可以将其投射为一种格式
SELECT CAST(ISNULL(REPLACE(REPLACE(a.[BPOFmv], '$',''),',',''), 0) AS DECIMAL(18,2)) AS BPOFmv
FROM [MyTables]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.