In general it's necessary to delete about 110K rows from table Nodes
but their id are not declared explicitly but are given from another table.
DECLARE @gh Table(id int);
INSERT INTO @gh (id) SELECT node_id FROM Relations;
DELETE FROM Nodes WHERE id NOT IN (SELECT DISTINCT id FROM @gh)
Selection (SELECT DISTINCT id FROM @gh
) contains about 20K rows and server couldn't delete them due to expired timeout. What other ways to do it are there?