CREATE TABLE example(id INT IDENTITY(1,1),name VARCHAR(20),class VARCHAR(20));
INSERT INTO example(name,class)VALUES('tam','1'); INSERT INTO example(name,class)VALUES('tam','1'); INSERT INTO example(name,class)VALUES('ram','1'); INSERT INTO example(name,class)VALUES('tam','2'); INSERT INTO example(name,class)VALUES('tam','1'); INSERT INTO example(name,class)VALUES('ram','1'); INSERT INTO example(name,class)VALUES('ram','2'); INSERT INTO example(name,class)VALUES('ram','2');
SELECT ROW_NUMBER() OVER(partition BY name,class ORDER BY id) AS dup FROM example;
WITH sample1 AS (SELECT ROW_NUMBER() OVER(partition BY name,class ORDER BY id) AS dup FROM example) DELETE FROM sample1 WHERE dup>1 GO
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.