使用带有Join语句的Open Query删除

时间:2015-04-12 17:24:27

标签: sql-server-2008

如何使用带有连接语句的SQL OPENQUERY删除

这是我的代码..这有什么问题?

delete from 
OPENQUERY(LINKSERVERNAME, 'SELECT Z.* from Project1.dbo.table1 Z') A
left join Project2.dbo.Table2 B on A.ID = B.ID
where B.ID is null

Project1数据库位于在线sql Server中 Project2数据库在我的本地sql Server

感谢

1 个答案:

答案 0 :(得分:1)

试试这个..

DELETE FROM A
FROM OPENQUERY([LINKSERVERNAME], 'SELECT Z.* from Project1.dbo.table1 Z') A
LEFT JOIN Project2.dbo.Table2 B ON A.ID = B.ID
WHERE B.ID is null