How to find values in all caps in SQL Server?

daveomcd picture daveomcd · Nov 17, 2011 · Viewed 54.3k times · Source

How can I find column values that are in all caps? Like LastName = 'SMITH' instead of 'Smith'

Here is what I was trying...

SELECT *
  FROM MyTable
 WHERE FirstName = UPPER(FirstName)

Answer

Alex K. picture Alex K. · Nov 17, 2011

You can force case sensitive collation;

select * from T
  where fld = upper(fld) collate SQL_Latin1_General_CP1_CS_AS