DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE
SITE SEARCH SQLUSA.com HEADLINES NEWS
SQL E/BOOKS   SQL 2014 PROGRAMMING   DOWNLOADS
SCRIPTS SQL 2005 SQL 2008 ARTICLES
SQL JOBS TWITTER FORMAT VIDEOS
How to perform case sensitive CASE in case insensitive database?

To get the equivalent of :

CASE
WHEN 'a' THEN 'Alabama'
WHEN 'A' THEN 'Arizona'
END

in a case insensitive database do the following:

CASE
WHEN char(97) THEN 'Alabama'
WHEN char(65) THEN 'Arizona'
END

-- Case sensitive compare with COLLATE

DECLARE  @string VARCHAR(128); SET @string = 'delta';

SELECT Col1 = @string

WHERE  PATINDEX('delta',@string COLLATE SQL_Latin1_General_CP1_CS_AS) > 0

GO

-- delta

-- (1 row(s) affected)

 

DECLARE  @string VARCHAR(128); SET @string = 'Delta';

SELECT Col1 = @string

WHERE  PATINDEX('delta',@string COLLATE SQL_Latin1_General_CP1_CS_AS) > 0

GO

-- (0 row(s) affected)

------------

 

Exam Prep 70-461
Exam 70-461
DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE