提示出錯:(注:field1是nvarchar類型)
Server: Msg 8114, Level 16, State 5, Line 1
Error converting data type nvarchar to numeric.
4 个解决方案
#1
field1有非数字字符
#2
select CAST((case when (field1 is null or isnumeric(field1)=1) then '0' else field1 end) as decimal(10,4)) from table1
#3
哦,错了:
select CAST((case when (field1 is null or isnumeric(field1)<>1) then '0' else field1 end) as decimal(10,4)) from table1
select CAST((case when (field1 is null or isnumeric(field1)<>1) then '0' else field1 end) as decimal(10,4)) from table1
#4
field1含有非数字字符
#1
field1有非数字字符
#2
select CAST((case when (field1 is null or isnumeric(field1)=1) then '0' else field1 end) as decimal(10,4)) from table1
#3
哦,错了:
select CAST((case when (field1 is null or isnumeric(field1)<>1) then '0' else field1 end) as decimal(10,4)) from table1
select CAST((case when (field1 is null or isnumeric(field1)<>1) then '0' else field1 end) as decimal(10,4)) from table1
#4
field1含有非数字字符