2016-09-22 127 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; 
相关问题