-----------------------DELETE duplicate values in a TABLE------------------------------------------
Code Varchar (1) NULL,
n smallint NULL
) ON [PRIMARY]
GO
--select * from TestTable
INSERT INTO dbo.TestTable
VALUES
('A',1),('A',2),('A',2),('B',1),('B',2),('B',3),('C',1),('C',1),('C',2)
;WITH x AS
(
select code,n,ROW_NUMBER() over(order by Code,n)AS DPC from TestTable
)
DELETE
FROM x
WHERE DPC > 1