As the title says, I've been running this command to delete some records from a table but I noticed that it wasn't deleting the same records listed if I ran a query selecting the TOP(X)
records right before.
Shouldn't the DELETE
command follow the same default ordering that SELECT
does? If not, why?
I don't know if it matters, but here is the delete command I'm running:
DELETE TOP (100000) t
FROM Ticket AS t
LEFT JOIN Series s on t.SeriesId = s.id
LEFT JOIN Payment p on t.id = p.TicketId
WHERE s.EndDate <= DATEADD(MONTH, -1, GETDATE()) AND t.ExportDate is null AND p.TicketId is null
For the select, just replace the first line with SELECT TOP(100000) t.*