Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

How to find SQL fields in all CAPS

Posted on 2010-11-24
Last Modified: 2012-05-10
One of the tables in my SQL database has a field that is, at times, being populated by a third-party software program.  It is populating this field in all caps.  Is there a way to do a query of this field to find instances where entire words are in all caps?  
Question by:lulichk
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 34209321

FROM tblName
WHERE column_name = UPPER(column_name)

Open in new window

LVL 17

Expert Comment

ID: 34209381
Actually it depends on your current sql servers collation. To use a case sensitive coallation, you can use that in your select statement. The following examples will return records from the table where the whole value is in UPPER CASE.


insert into #t(n) Values ('TEST')
insert into #t(n) Values ('zing')

Select *
Select *,
         CASE WHEN n COLLATE SQL_Latin1_General_CP1_CS_AS = LOWER(n) then 1 else 0 END Val
From #t ) m
Where Val = 0

Hope this helps


LVL 17

Expert Comment

ID: 34209427
Oops.. missed one important check. The value in the field could also be in PROPER CASE, meaning the first alphabet of the word could be capitalised and the rest of the body will be in LOWER CASE. So, in this case please refer to this example:

insert into #t(n) Values ('Vick')
INSERT INTO #t(n) Values ('TEST')
insert into #t(n) Values ('zing')

Select * 
		Select	*, 
				CASE WHEN RIGHT(n, Len(n)-1) COLLATE SQL_Latin1_General_CP1_CS_AS = LOWER(RIGHT(n, Len(n)-1)) then 1 
					 ELSE 0 
				END Val
		From #t 
	) m
Where Val = 0


Open in new window

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

LVL 16

Accepted Solution

EvilPostIt earned 50 total points
ID: 34211247
If your collation is not case sensitive then you can do the following

FROM tblName
WHERE column_name COLLATE Latin1_General_CS_AS= UPPER(column_name)

Obviously you can change the collation to the case senitive version of the one that you are currently using.

Author Comment

ID: 34230639
Thanks for your responses.  This is my first time I've posted a question and I'm very grateful for the help.  
LVL 16

Expert Comment

ID: 34230649
No probs, let me know if i can further assist.

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Agent Timeout 5 65
Analysis of table use 7 54
SQL query with cast 38 53
Clone table from one server.database to another server.database 24 35
Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question