| 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
|
| The World Leader
in SQL Server Training |
|