SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 uppercase in SQL
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sippon77
Starting Member

13 Posts

Posted - 10/27/2005 :  00:33:26  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
1907 Posts

Posted - 10/27/2005 :  02:01:06  Show Profile  Visit chiragkhabaria's Homepage  Send chiragkhabaria a Yahoo! Message  Reply with Quote
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

Edited by - chiragkhabaria on 10/27/2005 02:01:47
Go to Top of Page

Kristen
Test

United Kingdom
22431 Posts

Posted - 10/27/2005 :  02:08:41  Show Profile  Reply with Quote
SELECT *
FROM MyTable
WHERE UPPER(MyColumn) = MyColumn COLLATE Latin1_General_BIN

Kristen
Go to Top of Page

Hunglech
Starting Member

16 Posts

Posted - 10/27/2005 :  02:12:54  Show Profile  Reply with Quote
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 - 10/27/2005 :  02:16:43  Show Profile  Reply with Quote
Ah, Like Kristen'Solution
Go to Top of Page

Kristen
Test

United Kingdom
22431 Posts

Posted - 10/27/2005 :  02:27:16  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000