It gets the ID and row number
Places into a #temp table
Gets rit of rn=1
And updates my table.
But... is there a more efficient way to do this?
IF OBJECT_ID('tempdb..#temp') IS NOT NULL DROP TABLE #temp;SELECT AccommodationsID , ROW_NUMBER() OVER ( PARTITION BY ProspectID , TourID ORDER BY AccommodationsID DESC ) rnINTO #tempFROM dbo.everyware_t_accommodationsWHERE User10 <> 'Delete'ORDER BY AccommodationsID DESC;DELETE FROM #tempWHERE rn = 1;UPDATE aSET a.User10 = 'Delete'FROM everyware_t_accommodations a JOIN #temp t ON a.AccommodationsID = t.AccommodationsIDWHERE 1 = 1;