Check whether text is UPPER case in T-SQL

I have prepared small snippet which will help you check whether some text is UPPER case in T-SQL. I have not found any good example while Googling. You can easily update to code to check whether the text is lower case by replacing UPPER with LOWER in the snippet.

DECLARE @Name AS NVARCHAR(64)
SET @Name = 'NAME'

IF BINARY_CHECKSUM(@Name) = BINARY_CHECKSUM(UPPER(@Name))
SELECT 1;
ELSE
SELECT 0;

Leave a Reply

Your email address will not be published. Required fields are marked *