I completely agree that having a unique identifier will save you a lot of time.
But if you cannot use one (or if it is purely hypothetical), here is an alternative: Determine the number of rows to delete (the number of each individual value is -1), then run a loop and delete the top X for each individual value.
Please note that I am not responsible for the number of kittens that kill every time you use dynamic SQL.
declare @name varchar(50) declare @sql varchar(max) declare @numberToDelete varchar(10) declare List cursor for select name, COUNT(name)-1 from
Another alternative would be to create a view with a generated identifier. Thus, you can match the values ββwith a unique identifier (with the possibility of regular deletion) without constantly adding to the table.
source share