Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 compare upper and lower case

Author  Topic 

asgast
Posting Yak Master

149 Posts

Posted - 2010-12-02 : 04:32:34
The sql server I'm working on is configured to be case insensitive and I need a way to find uppercase words in a string. Does anyone have any ideas?

Sachin.Nand

2937 Posts

Posted - 2010-12-02 : 04:43:35
Can you provide some example?

PBUH

Go to Top of Page

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-12-02 : 04:47:03
Please check -
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=146284

Vaibhav T

If I cant go back, I want to go fast...
Go to Top of Page

asgast
Posting Yak Master

149 Posts

Posted - 2010-12-02 : 04:48:33
from the following string "this Is an Example, small ONE" the output should be:
Is
Example
ONE

I'm currently more interested in words where 1st letter is in uppercase, so:
Is
Example
would be a better output

Go to Top of Page

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-12-02 : 05:09:35
It will give correct output but is very complex to understand


DECLARE @Text AS VARCHAR(100)
SELECT @Text = 'this Is an Example, small ONE'

Declare @textXml Xml
Select @TextXml = Cast('<d>' + Replace(@Text, ' ','</d><d>') + '</d>' As Xml );
SELECT Data FROM
(
SELECT T.split.value('.', 'nvarchar(max)') AS data,
CASE WHEN ASCII(LEFT(T.split.value('.', 'nvarchar(max)'),1)) BETWEEN 56 AND 90
AND ASCII(SUBSTRING(T.split.value('.', 'nvarchar(max)'),2,1)) NOT BETWEEN 56 AND 90
THEN 1 Else 0 END FirstCap
FROM @textXML.nodes('/d') T (split)
) A
WHERE FirstCap = 1


Vaibhav T

If I cant go back, I want to go fast...
Go to Top of Page

dineshrajan_it
Posting Yak Master

217 Posts

Posted - 2010-12-02 : 07:02:03
quote:
Originally posted by vaibhavktiwari83

It will give correct output but is very complex to understand


DECLARE @Text AS VARCHAR(100)
SELECT @Text = 'this Is an Example, small ONE'

Declare @textXml Xml
Select @TextXml = Cast('<d>' + Replace(@Text, ' ','</d><d>') + '</d>' As Xml );
SELECT Data FROM
(
SELECT T.split.value('.', 'nvarchar(max)') AS data,
CASE WHEN ASCII(LEFT(T.split.value('.', 'nvarchar(max)'),1)) BETWEEN 56 AND 90
AND ASCII(SUBSTRING(T.split.value('.', 'nvarchar(max)'),2,1)) NOT BETWEEN 56 AND 90
THEN 1 Else 0 END FirstCap
FROM @textXML.nodes('/d') T (split)
) A
WHERE FirstCap = 1


Vaibhav T

If I cant go back, I want to go fast...



Good one.

Iam a slow walker but i never walk back
Go to Top of Page

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-12-02 : 07:11:14
@Dinesh : Thanks

Vaibhav T

If I cant go back, I want to go fast...
Go to Top of Page
   

- Advertisement -