Database2
出现错误
无法绑定多部分标识符
,我不明白为什么会这样。我看了其他的帖子,但我很难找到一个确切的答案,我做错了。
我的目标是将数据库2中的一列数据替换为数据库1中一个时间段之间的数据。
下面是我正在做的一个例子:
UPDATE Table1
SET Database1.dbo.Table1.Value1 = Database2.dbo.Table1.Value1
FROM Database1.dbo.Table1
INNER JOIN Database2.dbo.Table1.Value1 ON (Database1.dbo.Table1.Value1 = Database2.dbo.Table1.Value1)
WHERE Database1.dbo.Table1.Value1.Date_Time BETWEEN '2002-12-09 14:00:00.000' AND '2013-06-20 14:00:00.000';
这只是一个语法问题。为两个表指定别名
UPDATE d1_table
SET d1_table.Value1 = d2_table.Value1
FROM Database1.dbo.Table1 d1_table
INNER JOIN Database2.dbo.Table1 d2_table
ON d1_table.Value1 = d2_table.Value1)
WHERE d1_table.Value1 BETWEEN '2002-12-09 14:00:00.000' AND '2013-06-20 14:00:00.000';
需要用表连接表或列
UPDATE t1
SET
t1.Value1 = t2.Value1
FROM Database1.dbo.Table1 t1
INNER JOIN (SELECT Value1 FROM Database2.dbo.Table1) t2
ON ( t1.Value1 = t2.Value1)
WHERE t1.Date_Time BETWEEN '2002-12-09 14:00:00.000' AND '2013-06-20 14:00:00.000';