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 Chriss Miller 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
US
I want only uppercase words from a descripton field that starts with all upppercase words followed by: mixed case or numbers or hyphens or quotes, etc.
SET Desc = SUBSTRING(Desc,1,PATINDEX(only uppercase words);
 
Just to clarify...

If the DESC column looks like this...

[tt][blue]HELLO WORLD - this is just a test[/blue][/tt]

You want it to end up being...

[tt][blue]HELLO WORLD[/blue][/tt]

Is this correct?

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Take a look at this...

Code:
Declare @Temp VarChar(100)

Set @Temp = 'UPPER CASE words only'

Select SubString(@Temp, 1, PatIndex('%[^A-Z ]%', @Temp collate SQL_Latin1_General_CP850_BIN)-1)

Normally, SQL Server is not case sensitive (depending on your collation). By using a binary collation SQL_Latin1_General_CP850_BIN (or any other case sensitive collation), you can achieve your goals.



-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Select SubString(@Temp, 1, PatIndex('%[^A-Z ]%', @Temp collate SQL_Latin1_General_CP850_BIN)-1) gives me "syntax error near collate".
I tried it without the collate clause:
Select SubString(@Temp, 1, PatIndex('%[^A-Z ]%', @Temp)-1) and the result is just 'U'.
When I try it on live data, I get "cannot convert to a numeric".
 
I tested that block of code before posting. Are you using Microsoft SQL Server?

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Sorry. Server is Microsoft SQL Server but this app uses Sybase. Is there a thread for Sybase?
 
forum187

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top