【问题标题】:Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Chinese_PRC_CI_AS" in the equal to operation无法解决等于操作中“SQL_Latin1_General_CP1_CI_AS”和“Chinese_PRC_CI_AS”之间的排序规则冲突
【发布时间】:2020-01-25 03:44:05
【问题描述】:

如果我INNER JOIN tblMachine on b.strMachID = tblMachine.strMachID

出现此错误:

无法解决equal to操作中“SQL_Latin1_General_CP1_CI_AS”和“Chinese_PRC_CI_AS”之间的排序规则冲突。

这个错误是什么意思?这是我的查询。

select distinct b.strCostCentreID ,  b.strPOSOnlineRefNo, strPayTypeCode, b.strRemarks as Agency, tblMachine.strDesc As KName,
     (SUM(b.dblPaidAmt)) as RM   
     From tblCurrTrxMaster as b INNER JOIN tblMachine on b.strMachID = tblMachine.strMachID  
     WHERE  strPaymentMethod = '02' and (b.dtmCreated>='1/23/2020') AND (strTransStatus='01')
     GROUP BY b.strCostCentreID , b.strPOSOnlineRefNo, b.strPayTypeCode, b.strRemarks ,b.strMachID, tblMachine.strDesc

【问题讨论】:

  • 这意味着您正在尝试与具有不同排序规则的字符串列进行比较。请咨询documentation。理想情况下,您会更改其中一个排序规则,使它们都相同,否则您最终可能会遇到性能问题。作为一个简单的修复方法,在查询中使用 collat​​e 关键字来更改其中一列的排序规则以使其匹配。
  • 是的。我得到了它。非常感谢,我刚刚在表格设计器中删除了“Chinese_PRC_CI_AS”。
  • 除非您有充分的理由不这样做,否则最好在您的组织中使用相同的排序规则。这种对细节的关注对于避免这样的错误很重要。以后很难更改排序规则。

标签: sql sql-server


【解决方案1】:

您可以强制使用排序规则

select distinct b.strCostCentreID ,  b.strPOSOnlineRefNo, strPayTypeCode, b.strRemarks as Agency, tblMachine.strDesc As KName,
     (SUM(b.dblPaidAmt)) as RM   
     From tblCurrTrxMaster as b INNER JOIN tblMachine 
    on b.strMachID  COLLATE SQL_Latin1_General_CP1_CI_AS= tblMachine.strMachID  COLLATE SQL_Latin1_General_CP1_CI_AS
     WHERE  strPaymentMethod = '02' and (b.dtmCreated>='1/23/2020') AND (strTransStatus='01')
     GROUP BY b.strCostCentreID , b.strPOSOnlineRefNo, b.strPayTypeCode, b.strRemarks ,b.strMachID, tblMachine.strDesc

【讨论】:

    猜你喜欢
    • 2018-10-20
    • 2010-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多