我对链接服务器有一个SELECT语句,如下所示;
SELECT [TrackingId]
FROM [Server1\DB].[sctracking].[dbo].[scTracking] AS A
WHERE EXISTS (SELECT * FROM [Server2\DB].[sctracking].[dbo]. [scTracking] AS B
WHERE A.Reserved = B.Reserved )
这给了我想要的输出,但是实际上我想要做的就是删除结果。
谁能建议我将删除语句包装到其中吗?
答案 0 :(得分:1)
DELETE A FROM [Server1\DB].[sctracking].[dbo].[scTracking] A
WHERE EXISTS (SELECT *
FROM [Server2\DB].[sctracking].[dbo]. [scTracking] AS B
WHERE A.Reserved = B.Reserved)
答案 1 :(得分:1)
改为使用DELETE
语句:
DELETE A
FROM [Server1\DB].[sctracking].[dbo].[scTracking] AS A
WHERE EXISTS (SELECT 1
FROM [Server2\DB].[sctracking].[dbo].[scTracking] AS B
WHERE A.Reserved = B.Reserved
);