2011-01-28 62 views
0

我有一個SQL查詢是這樣的:SQL錯誤與 「Turkish_CI_AS」 和規則 「SQL_Latin1_General_CP1_CI_AS」

SELECT E.HESAP, B.TEKLIF_NO1 + '/' + 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 

但是當我運行它,我得到一個錯誤:

Server Error in '/' Application.
Cannot resolve the collation conflict between "Turkish_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.
Description: An unhandled exception occurred during the execution of the current web request.
Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Cannot resolve the collation conflict between "Turkish_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.

Source Error: Line 77: myConnection.Open(); Line 78: Line 79: SqlDataReader dr = myCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection); Line 80: Line 81: // show the data

我不能找到錯誤。它在哪裏?

回答

4

字面'/'將承擔該數據庫的默認排序規則。

嘗試

... B.TEKLIF_NO1 + '/' COLLATE Turkish_CI_AS + B.TEKLIF_NO2 AS 'TEKLIF' ... 
3

查看其中一個AND子句,其中的數據類型是VARCHAR類型。您將需要在哪裏確定排序,以確保您不會收到此錯誤。

EG:

WHERE B.TEKLIF_NO1 COLLATE SQL_Latin1_General_CP1_CI_AS = C.TEKLIF_NO1 COLLATE SQL_Latin1_General_CP1_CI_AS 
相關問題