Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UPPERCASE words only

Status
Not open for further replies.

trenttc

Technical User
Feb 25, 2002
68
0
0
US
I want all the uppercase words from a field that has upppercase words followed by other data. Ex: HELLO There becomes HELLO. I got this far: SET @temp = SUBSTRING(@temp,1,PATINDEX('%[^A-Z ]%',@temp-1));
 
Can't imagine why you need this but here goes
select i,d,reverse(
substring(reverse(substring(d+' a',1,PATINDEX('%[^A-Z ]%',d+' a')))
,charindex(' ',reverse(substring(d+' a',1,PATINDEX('%[^A-Z ]%',d+' a'))))
,len(d)+2)
) t
from (
select i=
1,'Hello there' d union all select
2,'HEllo there' union all select
3,'HELLO there' union all select
4,'HELLO There' union all select
5,'HELLO THere' union all select
6,'HELLO THERE' union all select
7,'HELLO THERE fool'
) a
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top