Wednesday, August 01, 2007 2:37 AM
by
ggsubscribe
COLLATION Revealed
Well, just in case you happen to develop applications that are so particular with sorting characters. You might want to check this out.
Supposing here is your data source from dbo.person:
Name
-----------
A
B
SIYV
SIY-Y
1
1A
1B
B1
A1
A.
A-
.A
-A
The following shows the differences between sorting in English (US) versus English (UK).
The following is the collation used for English (US).
SELECT name FROM dbo.person
ORDER BY name
COLLATE SQL_Latin1_General_CP1_CI_AS
Here is the result:
Name
-----------
-A
.A
1
1A
1B
A
A-
A.
A1
B
B1
SIY-Y
SIYV
The following is the collation used for English (UK).
SELECT name FROM dbo.person
ORDER BY name
COLLATE Latin1_General_CI_AS
Here is the result:
Name
-----------
.A
1
1A
1B
A
-A
A-
A.
A1
B
B1
SIYV
SIY-Y
There!
Hope this helps!
P.S. Sort the same data set in MS Excel. I used Excel 2007. It produced the same result as that of English (UK). But hmmm. I thought, Excel is using Windows Collation based on the Language Setting in Regional Settings. But seems it does not. I have not found the way on how to set collation in Excel if there is any. Anybody? So, is Excel set to sort using English (UK)?