DELETE from OPENQUERY alias not working I'm trying to use the following code to execute a DELETE statement on a linked server. I'm trying to delete all records from the remote server where there is a match on a certain ID field in both the table on the linked server and a local table. Any records showing up in the INNER JOIN should be deleted from the linked server table RemoteTable.

The following isn't allowing me to use an alias ("RemoteTable") for my remote table. Am I on the right track here with what I'm trying to accomplish? Thanks!

DELETE FROM OPENQUERY(LINKEDSERVER_MYSQL,'SELECT * from PrimaryInquiry_T2') AS RemoteTable
INNER JOIN Forms.dbo.PrimaryInquiry_TLOCAL AS LocalTable
ON LocalTable.PrimaryInquiry_TLOCAL_EntryID = RemoteTable.PrimaryInquiry_T2_EntryID
You should be able to use SQL Server's proprietary and admittedly awkward self-reference form of delete:

DELETE RemoteTable
  FROM OPENQUERY(...) AS RemoteTable ...