My SQL Server 2008 database is set to Latin1_General_100_CI_AI collation, yet when I query the database using Management Studio it is still accent sensitive. What am I missing?
Also, I get the following message when joining two tables on a nvarchar. The tables are both on the same collation too.
Cannot resolve the collation conflict between "Latin1_General_100_CI_AI" and "Latin1_General_CI_AS" in the equal to operation.
Any help would be greatly appreciated.
The documentation recommends SQL_Latin1_General_CP1_CI_AS as the recommended code page, but that is now considered obsolete in newer versions of MS SQL Server.
Collations in SQL Server provide sorting rules, case, and accent sensitivity properties for your data. Collations that are used with character data types, such as char and varchar, dictate the code page and corresponding characters that can be represented for that data type.
Default server-level collation is SQL_Latin1_General_CP1_CI_AS. If you are migrating databases from SQL Server to Managed Instance, check the server collation in the source SQL Server using SERVERPROPERTY(N'Collation') function and create a Managed Instance that matches the collation of your SQL Server.
It is absolutely possible to database with a different collation on a same SQL Server Instance. It is also possible to create an individual column in a table with different collations from server instance and database as well.
Try casting one of the fields into the other field's collation:
SELECT *
FROM as_table
JOIN ai_table
ON ai_field = as_field COLLATE Latin1_General_100_CI_AI
or
SELECT *
FROM ai_table
JOIN as_table
ON as_field = ai_field COLLATE Latin1_General_100_CI_AS
Note that casting a field makes the predicate unsargable against the index on this field.
Once you've already created objects inside the database, simply changing the collation doesn't change the existing objects. You can see this by right-clicking the tables and scripting them out - they'll have lots of notes about the collations of the varchar fields. If you want the objects to change, you'll need to recreate them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With