declare @test table (id nvarchar(50))
insert into @test(id)
values('123'), ('XYZ'), ('X12'), ('1X2'), ('12X'), ('?'), ('100'), (''), ('-'), ('+'),
('1. .2'), ('-89'), ('78-'), ('89+'), ('98'), ('009'), ('999')
select id from @test
select id from @test
where
id like '%[0-9]%' -- 包含0~9字符
and id not like '%[^-+.0-9]%' -- 不能包含-、+、.和0~9以外字符
过虑字段可转为数值的记录
本文转载:CSDN博客