I need to know if a string was all upper or all lower and was stumped for a case sensitive string comparison. Ultimately came up with this.
Better ideas???
-- case sensitive - not equal
IF (SELECT 'AbcdEfg' COLLATE Latin1_General_CS_AS) = 'abcdefg'
PRINT 'equal'
ELSE
PRINT 'not equal'
-- case insensitive - e
IF (SELECT 'AbcdEfg' COLLATE Latin1_General_CI_AS) = 'abcdefg'
PRINT 'equal'
ELSE
PRINT 'not equal'
Technorati tags: SQL