I am executing the code below for a table with 2 million plus records but NewID() is taking a long time to run.
Can you suggest an alternate method to make the query faster?
DELETE FROM Table1
WHERE ID NOT IN (SELECT TOP 60000 ID FROM Table1
WHERE flag <> '1'
ORDER BY NEWID())
AND
ID NOT IN(SELECT ID FROM Table1
WHERE flag = '1');