![]() Because both Collations use the same code page, the choice won't affect the character set being used. WHERE IN (N'Serbian_Latin_100_CI_AS', N'Croatian_CI_AS') Īt this point, you need to pick one of those two to force the other one to be the same. You can find this info out using the following query: SELECT col., COLLATIONPROPERTY(col., 'CodePage') AS I would advise against using database_default in this particular case since that will be relative to the database that the query is being executed from, which might lead to inconsistent behavior.įortunately, both Collations that are mentioned in the error have the same code page: 1250. However, since you have a collation mismatch, you need to change one of them. So, changing Collations on VARCHAR data can lead to data loss: SELECT CHAR(230) AS ,ĬHAR(230) COLLATE Korean_100_CI_AS AS ,ĬHAR(230) COLLATE Albanian_CI_AS AS ,ĬHAR(230) COLLATE Greek_100_CI_AS AS which code page is used to determine what character each 8-bit value represents). But for VARCHAR data, Collations also control the character set (i.e. For both NVARCHAR and VARCHAR data, Collations control sorting and comparison rules. Of course, if you have several columns with conflicting collations you will need to define their collations as well.Ĭollations can be a bit tricky, especially for VARCHAR data. SELECT Name COLLATE database_default from dbo.Croatian SELECT Name COLLATE database_default as CollatedNameDBDefault from dbo.Serbian Collate to the database default collation SELECT Name COLLATE Serbian_Latin_100_CI_AS from dbo.Croatian SELECT Name COLLATE Serbian_Latin_100_CI_AS as CollatedNameSerbian from dbo.Serbian Collate to a particular named collation INSERT INTO dbo.Croatian VALUES ('croation') INSERT INTO dbo.Serbian VALUES ('serbian') Here is a sample bit of code to help you: use testdbĬREATE TABLE dbo.Serbian (Name VARCHAR(20) COLLATE Serbian_Latin_100_CI_AS) ĬREATE TABLE dbo.Croatian (Name VARCHAR(20) COLLATE Croatian_CI_AS) Since you are trying to UNION two tables, using the column collation on the needed columns will resolve your query. Based on the collation names I assume that you are using Microsoft SQL Server.ĬOLLATE can be used at the database level or the column level.
0 Comments
Leave a Reply. |