2016-09-22 113 views
1

使用此代碼:我收到錯誤消息SQL 4104

UPDATE MyBase.dbo.Inventory 
SET Inventory.BarCode= Table1.Barcode 
FROM Market.dbo.Table1, MyBase.dbo.Inventory 
WHERE Table1.Barcode=Inventory.BarCode 

我收到錯誤消息:消息4104,級別16,狀態1,行 多部分標識符 「Table1.Barcode」 可能不受約束。

回答

2
UPDATE t2 
SET t2.BarCode= t1.Barcode 
FROM Market.dbo.Table1 t1 
join 
MyBase.dbo.Inventory t2 on t1.Barcode collate SQL_Latin1_General_CP1253_CI_AS=t2.BarCode collate SQL_Latin1_General_CP1253_CI_AS 

的問題是,由於您沒有使用數據庫名稱限定它,你可能不會在同一個數據庫中,也使用別名來使其更具可讀性..

還要檢查以下鏈接所有答案的更多在排序規則..

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

+0

我得到不正確的語法附近在哪裏 – DiH

+0

它應該是,我加了它 – TheGameiswar

+0

現在我收到錯誤:無法解決在等同於操作「SQL_Latin1_General_CP1253_CI_AS」和「Greek_CI_AS」之間的排序規則衝突。 – DiH

3

您應該使用明確連接對於這一點,並給你的表格進行適當的別名:

UPDATE I 
SET I.BarCode = T.Barcode 
FROM MyBase.dbo.Inventory I 
INNER JOIN Market.dbo.Table1 T 
    ON I.BarCode = T.Barcode;