--3楼错了吧!好象是包含数字的字段啊! --测试环境declare @t table (a varchar(10)) insert into @t select '-0111' union all select 'A2222' union all select 'ABB' union all select 'ABBT' union all select '222' union all select '222T' union all select '222-T' union all select '0' --测试 select * from @t where patindex('%[^-^0-9]%',a)=0 --结果 a ---------- -0111 222 0(所影响的行数为 3 行)
--测试环境declare @t table (a varchar(10))
insert into @t select '-0111'
union all select 'A2222'
union all select 'ABB'
union all select 'ABBT'
union all select '222'
union all select '222T'
union all select '222-T'
union all select '0'
--测试
select * from @t where patindex('%[^-^0-9]%',a)=0
--结果
a
----------
-0111
222
0(所影响的行数为 3 行)
'%[^-^.^0-9]% 中间有.没点怎么都能通过查询