How to understand collation of INFORMATION_SCHEMA.COLUMNS in Azure SQL Database?
I try to do this:
CREATE TABLE #SourceColumns (Id INT NOT NULL, Field VARCHAR(MAX) COLLATE DATABASE_DEFAULT NOT NULL);
insert into #SourceColumns values (1, 'test')
select * from INFORMATION_SCHEMA.COLUMNS join #SourceColumns on COLUMN_NAME = Field;
and I get the following error:
Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.
I know how I can fix it, but I want to understand it first.
I wanted to do this:
SELECT c.name AS column_name, c.collation_name
FROM sys.columns c
JOIN sys.tables t ON c.object_id = t.object_id
WHERE t.name="INFORMATION_SCHEMA.COLUMNS"
to see the collation of the COLUMN_NAME but I get an empty result.
Read more here: Source link