I'm attempting to run a
DELETE statement from my local SQL Server to delete appropriate records from a table in my remote linked server using
OPENQUERY(). I'm using the following code, but it seems slow and I don't want to be pounding my server with bad SQL. Should I be using
OPENQUERY() for this? Should I be deleting from it a different way that's more direct?
Here's my code:
DELETE RemoteTable FROM OPENQUERY(MyLinkedServer,'SELECT * from RemoteTable_T1') AS RemoteTable INNER JOIN MyDB.dbo.LocalTable_T1 AS LocalTable ON LocalTable.LocalTable_T1_EntryID = RemoteTable.RemoteTable_T1_EntryID;
Any improvements I can make on this code since it is going to be set up as a recurring task on my server? I have about 5 different variations of this in order to delete from 5 different tables on my linked server.