有关ms sql中isnumeric函数的问题

当我的id为TM200211261000d349,TM200211260000d349的时候
select substring(id,11,16) from test where isnumeric(substring(id,11,16))=1
这里的返回值是TM200211260000d349?
这是怎么回事呢?我认为截取下来的是0000d34不能转换的啊?
---------------------------------------------------------------

select isnumeric('0000d34') --返回1
select cast('0000d34' as float(28,8)) ----返回0.0


select isnumeric('0000c34') --返回0

D可能是一个比较特殊的字符,

上述功能可用下面的方法实现,当然感觉很不好。

select substring(id,11,16) from test where isnumeric(substring(replace(id,'d','c'),11,16))=1

---------------------------------------------------------------

The result should be '0000d349 '
what type of your id column, how long?
---------------------------------------------------------------

isnumeric()函数是有问题,执行:
select cast(substring(aa,11,16) as numeric) from a01 where isnumeric(substring(aa,11,16))=1
就不行:
Error converting data type varchar to numeric.

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus