如何在 SQL 服务器的 JOIN 中使用 COLLATE?
How to use the COLLATE in a JOIN in SQL Server?
我正在尝试连接两个表,但出现此错误:
Msg 468, Level 16, State 9, Line 8 Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and
"Latin1_General_CI_AS" in the equal to operation.
这是我使用的代码:
SELECT *
FROM [FAEB].[dbo].[ExportaComisiones] AS f
JOIN [zCredifiel].[dbo].[optPerson] AS p
ON (p.vTreasuryId = f.RFC) COLLATE Latin1_General_CI_AS
我知道错了,下划线COLLATE。我不知道如何应用它。
正确的语法如下所示。参见 MSDN。
SELECT *
FROM [FAEB].[dbo].[ExportaComisiones] AS f
JOIN [zCredifiel].[dbo].[optPerson] AS p
ON p.vTreasuryId COLLATE Latin1_General_CI_AS = f.RFC COLLATE Latin1_General_CI_AS
作为一般规则,您可以使用 Database_Default 排序规则,因此您无需确定使用哪一个。但是,我强烈建议阅读 Simons Liew 的优秀文章 Understanding the COLLATE DATABASE_DEFAULT clause in SQL Server
SELECT *
FROM [FAEB].[dbo].[ExportaComisiones] AS f
JOIN [zCredifiel].[dbo].[optPerson] AS p
ON (p.vTreasuryId = f.RFC) COLLATE Database_Default
我正在尝试连接两个表,但出现此错误:
Msg 468, Level 16, State 9, Line 8 Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation.
这是我使用的代码:
SELECT *
FROM [FAEB].[dbo].[ExportaComisiones] AS f
JOIN [zCredifiel].[dbo].[optPerson] AS p
ON (p.vTreasuryId = f.RFC) COLLATE Latin1_General_CI_AS
我知道错了,下划线COLLATE。我不知道如何应用它。
正确的语法如下所示。参见 MSDN。
SELECT *
FROM [FAEB].[dbo].[ExportaComisiones] AS f
JOIN [zCredifiel].[dbo].[optPerson] AS p
ON p.vTreasuryId COLLATE Latin1_General_CI_AS = f.RFC COLLATE Latin1_General_CI_AS
作为一般规则,您可以使用 Database_Default 排序规则,因此您无需确定使用哪一个。但是,我强烈建议阅读 Simons Liew 的优秀文章 Understanding the COLLATE DATABASE_DEFAULT clause in SQL Server
SELECT *
FROM [FAEB].[dbo].[ExportaComisiones] AS f
JOIN [zCredifiel].[dbo].[optPerson] AS p
ON (p.vTreasuryId = f.RFC) COLLATE Database_Default