当前位置: 首页 > 面试题库 >

SQL错误Turkish_CI_AS和SQL_Latin1_General_CP1_CI_AS

姜宏放
2023-03-14
问题内容

我在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.

有人对此错误有想法吗?


问题答案:

我认为您还需要通过表达式在您的组中复制您的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


 类似资料:
  • 问题内容: 我正在尝试使用PHP从MySQL的表中选择最后一条记录。我相信我有一个SQL错误。这是我的SQL代码: 如果这是有效的,并且我实际上有PHP错误,请告诉我。 问题答案: 您的SQL语法无效。使用 LIMIT 代替 试试这个: 该子句适用于MSSQL服务器。

  • 我正在运行以下SQL语法: 但不管用。我得到了这个错误: 错误1064(42000):您的SQL语法中有错误;查看与您的MySQL server版本相对应的手册,了解第1行“DISTINCT >”Number of Employees“FROM Hours”附近使用的正确语法 你能告诉我我在哪里做错了吗?对不起,我对MySQL和数据库不熟悉。

  • 问题内容: 我正在尝试在T-SQL中创建一些脚本变量,如下所示: 但是,当我运行此命令时,出现错误,指出“’:’附近的语法不正确”。我究竟做错了什么? 问题答案: :setvar仅在SQL命令模式下工作,因此您可能处于Management Studio的常规SQL执行范围内,而没有切换到命令模式。 这可以通过SQL Server Management Studio中的用户界面来完成,方法是转到“查

  • 请帮我解决这个问题。多谢了。

  • org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: The 'JSON_EXTRACT(all_info, '$' property of null is not a List or Array. 关键是这个sql 用navi

  • 我在执行触发器时遇到以下错误: 请说明问题的原因。 编辑 数据类型: