首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

查询空格后的 字母,该怎么解决

2012-05-01 
查询空格后的 字母查询一个单词 。每个 空格后 的一个字母 不是大写的记录 。如:Aaogn ajgnBfngComVfagC Com

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


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 allselect 'Bfng Com' union allselect '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 allselect 'Bfng Com  ' union allselect '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 allselect 'Bfng Com  ' union allselect '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 allselect 'Bfng Com' union allselect 'Vfag c Com'select * from [tb] where ascii(substring(name,charindex(' ',name)+1,1)) between 97 and 122这样插入就不对了结果显示为:nameAaogn ajgnVfag c Com 

热点排行