日期:2014-05-18 浏览次数:20471 次
--> 测试数据:[tb] if object_id('[tb]') is not null drop table [tb] go create table [tb]([name] varchar(20)) insert [tb] select 'Aaogn ajgn' union all select 'Bfng Com' union all select 'Vfag C Com' --------------开始查询-------------------------- select * from [tb] where ascii(substring(name,charindex(' ',name)+1,1)) between 97 and 122 /* name -------------------- Aaogn ajgn (1 行受影响) */
------解决方案--------------------
declare @tb table(ssf varchar(120)) insert into @tb select 'Aaogn ajgn' union all select 'Bfng Com ' union all select 'Vfag C Com' select * from @tb where ASCII(SUBSTRING(SSF,CHARINDEX(' ',ssf,1)+1,1)) not between 65 AND 90
------解决方案--------------------
declare @tb table(ssf varchar(120)) insert into @tb select 'Aaogn ajgn' union all select 'Bfng Com ' union all select 'Vfag C Com' select * from @tb where ASCII(SUBSTRING(SSF,CHARINDEX(' ',ssf,1)+1,1)) not between 65 AND 90
------解决方案--------------------
create table [#tb]([name] varchar(20)) insert [#tb] select 'Aaogn ajgn' union all select 'Bfng Com' union all select 'Vfag c Com' select * from [tb] where ascii(substring(name,charindex(' ',name)+1,1)) between 97 and 122 这样插入就不对了 结果显示为: name Aaogn ajgn Vfag c Com