Salient Solutions

wrasslin ones and nones for fun and profit - Sky Sanders' Blog
posts - 96, comments - 70, trackbacks - 0

TSQL Case sensitive string comparison on case insensitive server

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:

Print | posted on Saturday, January 23, 2010 1:05 PM |

Feedback

No comments posted yet.

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 3 and 6 and type the answer here:

Powered by: