Is there an efficient way to delete records from SQL Server without using the keyword IN
in the below scenario:
-- If Documents were deleted, remove them from your ocean
DELETE FROM IndexHistory
WHERE DocId IN (SELECT IH.Docid
FROM IndexHistory IH
LEFT JOIN IndexedLineItems I ON IH.Docid = I.DocId
WHERE I.Docid IS NULL)
If you study this scenario, you have all the records you want to delete from the query inside the parenthesis.
It is documented fact that using 'IN' is inefficient. So one would think that there should be a way to delete these without the 'IN', because all your records are identify-able without using the "IN".
So for example, I am thinking that something like this might be possible, but I don't have the right syntax:
DELETE FROM IndexHistory IH
LEFT JOIN IndexedLineItems I ON IH.Docid = I.DocId
WHERE I.Docid IS NULL
I appreciate the answer may still be "no, it's not possible."
If it is not possible, maybe it can be a possible suggestion to improve the language for Microsoft. Before I do that, I thought I would post here to see if I'm missing something.