• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 336
  • Last Modified:

Search for lowercase instances in a case-insensitive column

I have a table in my SQL Server 2005 database that contains customer IDs.  Example:
CULSTA2
culsta2
BILBOA
SUNSUP
AQUCON
aqucon

and so on.  I need to be able to identify anytime there's an entry of any lower case entry, separate from the correct entry of all upper case.  My database is set as case-insensitive but the application that uses it interprets the data differently if it is lower case rather than all upper case.

So in the set shown above, I'd just be looking for culsta2 and aqucon, and NOT CULSTA2 or AQUCON.

Help?
Thanks
Van

0
ngwsls
Asked:
ngwsls
  • 2
1 Solution
 
sgvillCommented:
Anytime you use it, you could send it as UPPER(ID).  
0
 
Rajkumar GsSoftware EngineerCommented:
SELECT * FROM urTable WHERE urfield = LOWER(urfield) COLLATE SQL_Latin1_General_CP1_CS_AS

Raj
0
 
sgvillCommented:
oops. misread what you wrote.  You can use a query like this:

select * from yourtable where cast(ID as varbinary(100)) <> cast(upper(ID) as varbinary(100))

and your varbinary can be as small as your IDs are
0
 
ngwslsAuthor Commented:
Perfect!  It worked!  Thanks so much!
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now