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 2000 Forums
 SQL Server Development (2000)
 uppercase in SQL

Author  Topic 

sippon77
Starting Member

13 Posts

Posted - 2005-10-27 : 00:33:26
How can i figure out..
if a string is completely in uppercase?
or
if a string is not in title case (ie: The first letter of a word is in Uppercase and remaining are in lower case).

Thanks in advance.

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2005-10-27 : 02:01:06
It would be better if you can do this in front end since there are lots of ready made In built functions for the same.

But you can trying using ASCII functions of the SQL for the same.

Hope the following scripts helps you..

For checking the Upper

Declare @var Varchar(1000)
Set @Var = 'SOMEVALUE'
IF ASCII(@Var) = ASCII(Upper(@var))
Print 'Its in the Upper Case'
Else
Print 'Its Not in the upper CAse'


--- for the title case

IF ASCII(LEft(@Var,1)) = ASCII(Upper(Left(@Var,1)))
Print 'its the Title Case'
Else
Print 'Its Not The Title Case. '




Complicated things can be done by simple thinking
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-10-27 : 02:08:41
SELECT *
FROM MyTable
WHERE UPPER(MyColumn) = MyColumn COLLATE Latin1_General_BIN

Kristen
Go to Top of Page

Hunglech
Starting Member

16 Posts

Posted - 2005-10-27 : 02:12:54
You can use
IF @Var COLLATE Latin1_General_BIN = UPPER(@Var)
RETURN 1
ELSE
RETURN 0
Go to Top of Page

Hunglech
Starting Member

16 Posts

Posted - 2005-10-27 : 02:16:43
Ah, Like Kristen'Solution
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-10-27 : 02:27:16
Of all of the BINary collations, in all of SQL server, in all of SQL Team ... you choose mine

With apologies to Humphrey Bogart and Casablanca!

Kristen
Go to Top of Page
   

- Advertisement -