2011-04-11 64 views
1

我正在嘗試在兩個鏈接的服務器上編寫查詢。已經設立具有適當的登錄鏈接,我得到這個整理錯誤:如何在T-SQL中正確構造collat​​e命令?

Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation.

這是新的給我,但它看起來像一個字符集衝突,所以我用Google搜索,並發現了分頁打印指令從而可以被添加到我的加入。但是我都試過

va ON V_ID1 = c1.strData COLLATE Latin1_General_CI_AS 

va ON V_ID1 = c1.strData COLLATE SQL_Latin1_General_CP1_CI_AS 

而且,無論似乎解決錯誤。我究竟做錯了什麼?

編輯:整個查詢太大張貼,並期望人們過濾通過,但這裏的相關位:

select 
     rel.intParentAttributeId as intItemId, 
     case va.type 
     when 'SM' then 120000000 
     when 'FB' then 110000000 
     when 'RO' then 100000000 
     when 'SP' then 90000000 
     when 'A' then 80000000 
     when 'D' then 70000000 
     when 'P' then 60000000 
     when 'SR' then 50000000 
     when 'FN' then 40000000 
     when 'RL' then 30000000 
     when 'VO' then 20000000 
     when 'RE' then 10000000 
     end 
     + 

     rel.intParentAttributeId 
     as fltStrength 
     from 
     AttributeMap ky 

     join Catalogue c1 on c1.intRowId=ky.intChildAttributeId and [email protected] 

     join 

     [SQLSERVERNAME].[SchemaName].dbo.VidAssc 
     va on V_ID1 COLLATE SQL_Latin1_General_CP1_CI_AS = c1.strData COLLATE SQL_Latin1_General_CP1_CI_AS 


     join Catalogue c2 on c2.strData=V_ID2 and [email protected] 

     join AttributeMap rel on rel.intChildAttributeId = c2.intRowId 

     join @tmpSeeds s on s.intItemId = ky.intParentAttributeId 

     group by rel.intParentAttributeId,va.Type 

     )sqi 

乾杯, 馬特

+1

你能請張貼整個查詢?那裏可能有些東西你認爲是理所當然的。 – 2011-04-11 16:30:40

回答

2

好的,終於找到了一個修復。以下是你需要做的:

在sql server管理器中找到Server Objects> Linked Servers>並找到有問題的鏈接服務器。

右鍵點擊>屬性

在服務器選項設置爲「使用遠程排序規則」爲「False」 和「排序規則名稱」爲「Latin1_General_CI_AS」

2

嘗試把COLLATE左側以及:

FROM Table1 AS t1 
INNER JOIN Table2 AS t2 
ON t1.ID COLLATE Latin1_General_CI_AS 
    = t2.ID --COLLATE Latin1_General_CI_AS --optionally on the right if needed. 
+0

嗨。感謝您的幫助。嘗試此操作會導致錯誤:無法解決等於操作中「SQL_Latin1_General_CP1_CI_AS」和「Latin1_General_CI_AS」之間的排序規則衝突。 – 2011-04-12 08:35:22