无法解决排序规则冲突 - SQL Server 2008 R2 SP1
Posted
技术标签:
【中文标题】无法解决排序规则冲突 - SQL Server 2008 R2 SP1【英文标题】:Cannot resolve the collation conflict - SQL Server 2008 R2 SP1 【发布时间】:2016-01-04 10:42:06 【问题描述】:我正在尝试运行以下查询:
SELECT [id]
,[company_id]
,[entry_no_]
,[project_no_sk]
,[project_no_]
,[task_code_sk]
,[task_code]
,[resource_code_sk]
,[resource_code]
,[work_type_code_sk]
,[work_type_code]
,[date_sk]
,[date]
,(SELECT [Price]
FROM [helios_navision_data_mart].[dbo].[dim_resource_prices]
WHERE [Project No_] = [project_no_]
AND [Work Type Code] = [work_type_code]
AND [Task Code] = CASE WHEN [Task Code] IN (task_code)
THEN task_code
ELSE ''
END
) as [Unit Price]
,[quantity]
FROM [dbo].[fact_operational_time_entry]
WHERE project_no_ = 'CHM-001'
AND [chargeable] = 'Yes'
AND [approved] = 'No'
但是在执行这个查询时我收到了错误:
Msg 468, Level 16, State 9, Line 17
Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CS_AS" and "Latin1_General_CS_AS" in the equal to operation.
我已经检查了表格、数据库和服务器的排序规则,它们都有“Latin1_General_CS_AS”作为排序规则定义。 错误发生在 WHERE 子句中的某处,但我看不到在哪里..因为排序规则相同。
有人有想法吗?请帮忙。
韩国, 凯文
【问题讨论】:
【参考方案1】:不知道为什么,但我不得不修改子查询以强制更改排序规则..
,(SELECT [Price]
FROM [helios_navision_data_mart].[dbo].[dim_resource_prices]
WHERE [Project No_] = [project_no_] COLLATE Latin1_General_CS_AS
AND [Work Type Code] = [work_type_code] COLLATE Latin1_General_CS_AS
AND [Task Code] = (CASE WHEN [Task Code] IN ([task_code] COLLATE Latin1_General_CS_AS)
THEN [task_code] COLLATE Latin1_General_CS_AS
ELSE ''
END)
) as [Unit Price]
【讨论】:
以上是关于无法解决排序规则冲突 - SQL Server 2008 R2 SP1的主要内容,如果未能解决你的问题,请参考以下文章