保留列是一个varchar,对它执行求和我想将它转换为deciaml.
但下面的sql给了我一个错误
但下面的sql给了我一个错误
select cast(Reserve as decimal) from MyReserves
将数据类型varchar转换为数字时出错.
我添加了isnumeric而不是null来尝试避免这个错误,但它仍然存在,任何想法为什么?
select cast(Reserve as decimal) from MyReserves where isnumeric(Reserve ) = 1 and MyReserves is not null
解决方法
似乎isnumeric有一些问题:
http://www.sqlhacks.com/Retrieve/Isnumeric-problems
(通过互联网档案)
select cast(Reserve as decimal) from MyReserves where MyReserves is not null and MyReserves * 1 = MyReserves