Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools


This script demonstrates the COLLATION capabilities in SQL Server 2000.

Click here to copy the following block
-- Ordering on case insensitive server
SELECT 'a' AS String
UNION ALL
SELECT 'b'
UNION ALL
SELECT 'A'
UNION ALL
SELECT 'B'
ORDER BY String;
/*
String
------
a
A
b
B
*/


/*
    Case sensitive sorting by modifying the collation of the data.
    This technique can be used to convert data from one collation to
    another also. The COLLATE clause can be used in comparisions also.
*/

SELECT *
FROM (
    SELECT 'a'
    UNION ALL
    SELECT 'b'
    UNION ALL
    SELECT 'A'
    UNION ALL
    SELECT 'B'
) AS c( String )
ORDER BY CAST( String as varchar ) COLLATE SQL_Latin1_General_CP850_CS_AS
/*
String
------
A
a
B
b
*/


-- Tip from BOL:
-- To see a list of valid collations, do:
SELECT * FROM ::fn_helpcollations()
-- Sample Output:
/*
name                 description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_Latin1_General_CP850_CI_AS    Latin1-General, case-insensitive, accent-sensitive, kanatype-insensitive, width-insensitive for Unicode Data, SQL Server Sort Order 42 on Code Page 850 for non-Unicode Data
SQL_Latin1_General_CP850_CS_AS    Latin1-General, case-sensitive, accent-sensitive, kanatype-insensitive, width-insensitive for Unicode Data, SQL Server Sort Order 41 on Code Page 850 for non-Unicode Data
SQL_Latin1_General_Pref_CP1_CI_AS   Latin1-General, case-insensitive, accent-sensitive, kanatype-insensitive, width-insensitive for Unicode Data, SQL Server Sort Order 53 on Code Page 1252 for non-Unicode Data
SQL_Latin1_General_Pref_CP437_CI_AS  Latin1-General, case-insensitive, accent-sensitive, kanatype-insensitive, width-insensitive for Unicode Data, SQL Server Sort Order 33 on Code Page 437 for non-Unicode Data
SQL_Latin1_General_Pref_CP850_CI_AS  Latin1-General, case-insensitive, accent-sensitive, kanatype-insensitive, width-insensitive for Unicode Data, SQL Server Sort Order 43 on Code Page 850 for non-Unicode Data
*/


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.