日期:2014-05-18  浏览次数:20488 次

查询空格后的 字母
查询一个单词 。每个 空格后 的一个字母 不是大写的记录 。如:


Aaogn ajgn
Bfng Com 
Vfag C Com 


那么 查出的记录 就应该是 Aaogn ajgn  

先谢谢 了各位



------解决方案--------------------
SQL code
--> 测试数据:[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 行受影响)
*/

------解决方案--------------------
SQL code
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

------解决方案--------------------
SQL code

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

------解决方案--------------------
SQL code
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