What is Database collation?

I was think of making it simpler, but i was not able to make it more simpler than this from BOL:

Collations specify the rules for how strings of character data are sorted and compared, based on the norms of particular languages and locales. For example, in an ORDER BY clause, an English speaker would expect the character string ‘Chiapas’ to come before ‘Colima’ in ascending order. But a Spanish speaker in Mexico might expect words beginning with ‘Ch’ to appear at the end of a list of words starting with ‘C’. Collations dictate these kinds of sorting and comparison rules. The Latin_1 General collation will sort ‘Chiapas’ before ‘Colima’ in an ORDER BY ASC clause, while the Traditional_Spanish collation will sort ‘Chiapas’ after ‘Colima’.

some times you might end up with a error like this in your SQL results:

Msg 468, Level 16, State 9, Line 1
Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "SQL_Latin1_General_Pref_CP1_CI_AS" in the equal to operation.

This issues/error can arise if there are cross server queries. Queries between SQL Server 2000 and 2005, the database collations are set differently between these objects.

Solution: under the Where clause or in the table join condition in your Query use COLLATE DATABASE_DEFAULT

SELECT c.something
FROM things
WHERE c.something COLLATE DATABASE_DEFAULT
IN (Select distinct something from things2 where something = ”)

Or if the Table you are using in your join condition eg as: (this is just a example, pl do not start puling legs :) )

LEFT JOIN server1.mydb1.dbo.table1 B ON a.codeid= B.codeid COLLATE DATABASE_DEFAULT

© 2010 D B A N A T I O N Suffusion WordPress theme by Sayontan Sinha
Better Tag Cloud