表里有一个varchar(20)的字段,字段中存储的是可以转换为real数据类型的数字。
id col1
---------------
1 123
2 12.3
3 45.75
4 12.3.4
5 12-3
很明显,第四条和第五条里col1的值不能转换为real数据类型求一个SQL语句来定位这些记录我的思路是找到 not like '数字.数字' and not like '数字' 的记录,但是不知道这样的语句怎么写,救命啊!!!
id col1
---------------
1 123
2 12.3
3 45.75
4 12.3.4
5 12-3
很明显,第四条和第五条里col1的值不能转换为real数据类型求一个SQL语句来定位这些记录我的思路是找到 not like '数字.数字' and not like '数字' 的记录,但是不知道这样的语句怎么写,救命啊!!!
go
insert into tb select 1,'123 '
insert into tb select 2,'12.3 '
insert into tb select 3,'45.75 '
insert into tb select 4,'12.3.4'
insert into tb select 5,'12-3 '
go
select * from tb where isnumeric(col1)=0
go
drop table tb;
go--结果
id col1
----------- --------------------
4 12.3.4
5 12-3 (2 行受影响)
select * from table where isnumeric(col1)=1 --应该是等于1
晕 我发帖的占座的功夫 怎么多人
select * from table where isnumeric(col1)=0