create table test2
(
TestId UNIQUEIDENTIFIER not null ,
AddedOn varchar(50) not null,
Action varchar(50) not null,
Item int not null,
Parent int not null,
Param int not null,
BoolParam int not null,
Content int not null,
Proprties int not null,
)
SELECT * FROM dbo.test2
INSERT INTO test2 VALUES (NEWID(),'1','1','1','1','1','1','1','1')
INSERT INTO test2 VALUES (NEWID(),'3','3','3','3','3','3','3','3')
DELETE T FROM (SELECT ROW_NUMBER() OVER(PARTITION BY Action ORDER BY Action) AS ROWNUMBER,* FROM test2 ) T
WHERE T.ROWNUMBER>1
DELETE t1
FROM test2 t1
WHERE t1.TestId >
(
SELECT MIN(t2.TestId)
FROM test2 t2
WHERE t1.Action = t2.Action
GROUP BY Action
HAVING COUNT(Action) > 1
);