小编典典

SQL错误Turkish_CI_AS和SQL_Latin1_General_CP1_CI_AS

sql

我在SQL SERVER 2008中有这样的查询。这正在工作。

SELECT C.HESAP_NO, B.TEKLIF_NO1 + '/' + B.TEKLIF_NO2 AS 'TEKLIF',
    C.MUS_K_ISIM,CONVERT(VARCHAR(10),B.ISL_TAR,103) AS 'TARIH', SUM(
    ISNULL(CAST(B.ODENEN_ANAPARA AS FLOAT),0)+ISNULL(CAST(B.FAIZ AS FLOAT),0)+
    ISNULL(CAST(B.BSMV AS FLOAT),0)+ISNULL(CAST(B.GECIKME_FAIZ AS FLOAT),0)+
    ISNULL(CAST(B.GECIKME_BSMV AS FLOAT),0)) AS 'YATAN', 
    (CASE WHEN C.DOVIZ_KOD = 21 THEN 'EUR' WHEN C.DOVIZ_KOD = 2 THEN 'USD' WHEN C.DOVIZ_KOD = 1 THEN 'TL' END) AS 'KUR', D.T_SR_ACK

    FROM TAKIP A, YAZ..MARDATA.BIR_TAHSIL B, 
    YAZ..MARDATA.S_TEKLIF C,P_TAKIP_SR D

    WHERE B.TEKLIF_NO1 = C.TEKLIF_NO1
    AND B.TEKLIF_NO2 = C.TEKLIF_NO2
    AND A.T_HESAP_NO = C.HESAP_NO
    AND A.T_SRM = D.T_SR_ID
    AND A.T_STATU = 2
    AND A.T_SRM <> 6
        GROUP BY C.HESAP_NO, B.TEKLIF_NO1 + '/' + B.TEKLIF_NO2, C.MUS_K_ISIM,B.ISL_TAR,C.DOVIZ_KOD, D.T_SR_ACK

但是,当我对此查询几乎没有变化时;

SELECT E.HESAP, B.TEKLIF_NO1 + '/' COLLATE Turkish_CI_AS + B.TEKLIF_NO2 AS 'TEKLIF',
    E.MUSTERI,CONVERT(VARCHAR(10),B.ISL_TAR,103) AS 'TARIH', SUM(
    ISNULL(CAST(B.ODENEN_ANAPARA AS FLOAT),0)+ISNULL(CAST(B.FAIZ AS FLOAT),0)+
    ISNULL(CAST(B.BSMV AS FLOAT),0)+ISNULL(CAST(B.GECIKME_FAIZ AS FLOAT),0)+
    ISNULL(CAST(B.GECIKME_BSMV AS FLOAT),0)) AS 'YATAN', 
    (CASE WHEN C.DOVIZ_KOD = 21 THEN 'EUR' WHEN C.DOVIZ_KOD = 2 THEN 'USD' WHEN C.DOVIZ_KOD = 1 THEN 'TL' END) AS 'KUR',
    E.AVUKAT, CONVERT(VARCHAR(10),A.ICRA_TAR,103) AS '陌CRA TAR陌H陌', CONVERT(VARCHAR(10),A.HACIZ_TAR,103) AS 'HAC陌Z TAR陌H陌'
    FROM TAKIP A, YAZ..MARDATA.BIR_TAHSIL B, 
    YAZ..MARDATA.S_TEKLIF C,P_TAKIP_SR D, AVUKAT E
    WHERE B.TEKLIF_NO1 = C.TEKLIF_NO1
    AND B.TEKLIF_NO2 = C.TEKLIF_NO2
    AND A.T_HESAP_NO = C.HESAP_NO
    AND C.HESAP_NO = B.HESAP_NO
    AND B.HESAP_NO = E.HESAP
    AND A.T_SRM = D.T_SR_ID
    AND A.T_STATU = 2
    AND A.T_SRM <> 6
GROUP BY C.HESAP_NO, B.TEKLIF_NO1 + '/' + B.TEKLIF_NO2,B.ISL_TAR,C.DOVIZ_KOD, E.HESAP, E.MUSTERI, E.AVUKAT, A.ICRA_TAR, A.HACIZ_TAR

我收到这样的错误

Msg 468, Level 16, State 9, Line 16
Cannot resolve the collation conflict between "Turkish_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.

有人对此错误有想法吗?


阅读 229

收藏
2021-03-08

共1个答案

小编典典

我认为您还需要通过表达式在您的组中复制您的collat​​e子句:

SELECT E.HESAP, B.TEKLIF_NO1 + '/' COLLATE Turkish_CI_AS + B.TEKLIF_NO2 AS 'TEKLIF',
    E.MUSTERI,CONVERT(VARCHAR(10),B.ISL_TAR,103) AS 'TARIH', SUM(
    ISNULL(CAST(B.ODENEN_ANAPARA AS FLOAT),0)+ISNULL(CAST(B.FAIZ AS FLOAT),0)+
    ISNULL(CAST(B.BSMV AS FLOAT),0)+ISNULL(CAST(B.GECIKME_FAIZ AS FLOAT),0)+
    ISNULL(CAST(B.GECIKME_BSMV AS FLOAT),0)) AS 'YATAN', 
    (CASE WHEN C.DOVIZ_KOD = 21 THEN 'EUR' WHEN C.DOVIZ_KOD = 2 THEN 'USD' WHEN C.DOVIZ_KOD = 1 THEN 'TL' END) AS 'KUR',
    E.AVUKAT, CONVERT(VARCHAR(10),A.ICRA_TAR,103) AS '陌CRA TAR陌H陌', CONVERT(VARCHAR(10),A.HACIZ_TAR,103) AS 'HAC陌Z TAR陌H陌'
    FROM TAKIP A, YAZ..MARDATA.BIR_TAHSIL B, 
    YAZ..MARDATA.S_TEKLIF C,P_TAKIP_SR D, AVUKAT E
    WHERE B.TEKLIF_NO1 = C.TEKLIF_NO1
    AND B.TEKLIF_NO2 = C.TEKLIF_NO2
    AND A.T_HESAP_NO = C.HESAP_NO
    AND C.HESAP_NO = B.HESAP_NO
    AND B.HESAP_NO = E.HESAP
    AND A.T_SRM = D.T_SR_ID
    AND A.T_STATU = 2
    AND A.T_SRM <> 6
GROUP BY C.HESAP_NO, B.TEKLIF_NO1 + '/' COLLATE Turkish_CI_AS + B.TEKLIF_NO2,B.ISL_TAR,C.DOVIZ_KOD, E.HESAP, E.MUSTERI, E.AVUKAT, A.ICRA_TAR, A.HACIZ_TAR
2021-03-08