首页 > 解决方案 > 如何使用本地服务器数据库中的 where 条件从链接服务器表中删除数据

问题描述

我有两个要同步的数据库,我想从托管数据库表而不是本地数据库表中删除数据..我的表名是全局的

我正在使用 sql server 2008R2

预先感谢您的帮助

delete [sql5025.site4now.net].DB_9BDE_alfaSuit.dbo.[global] where no not in (select no from [global])

标签: sqlsql-server

解决方案


只需添加本地数据库的别名。

delete [sql5025.site4now.net].DB_9BDE_alfaSuit.dbo.[global] where no not in 
(select no from DB_9BDE_alfaSuit.dbo.[global])

这将从链接服务器返回数据

select * from [sql5025.site4now.net].DB_9BDE_alfaSuit.dbo.[global] 

这将从本地服务器返回数据

select * from DB_9BDE_alfaSuit.dbo.[global] 

推荐阅读