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 ORDER BY case insensitive in a case sensitive database?

You can use the COLLATE attribute to get a different sort order. Here is an example for demonstration only since AdventureWorks database is case insensitive.

USE AdventureWorks;

 

SELECT   ProductName = p.Name,

         osod.SalesOrderID,

         osod.ProductID

FROM     Sales.SalesOrderDetail osod

         INNER JOIN Production.Product p

           ON p.ProductID = osod.ProductID

WHERE    osod.OrderQty >  ALL (SELECT isod.OrderQty

                               FROM   Sales.SalesOrderDetail isod

                                      JOIN Production.Product prd

                                        ON isod.ProductID = prd.ProductID

                               WHERE  prd.Class IN ('M'))

ORDER BY p.Name COLLATE SQL_Latin1_General_CP1_CI_AS

 

Case sensitive matching (search, compare) in case insensitive collation:

 

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

SELECT Col1 = @string

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

GO

-- alpha

-- (1 row(s) affected)

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

SELECT Col1 = @string

WHERE  PATINDEX('alpha',@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