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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s