Sql Server Remove Duplicate Value From a Table

How to Remove Duplicate Value From a Table

If We have a table like following and we need to remove Duplicate Value

ID FNAME LNAME
1 AAA CCC
2 BBB DDD
1 AAA CCC
2 BBB DDD
1 AAA CCC
2 BBB DDD
3 BCB DGD

If we want to remove duplicate value from above table
Than we can use following Query

SELECT DISTINCT * INTO NEWTABLE FROM OLDTABLE
TRUNCATE TABLE OLDTABLE
INSERT INTO OLDTABLE SELECT * FROM NEWTABLE

Sql Server Remove Duplicate Value From a Table

Leave a comment