Delete Duplicate Rows SQL Server

1. Add an Identity Column to the Table

alter table MASTER
add identity_col int identity(1,1);

2. Delete duplicate data using Below Query (In the GROUP BY CLAUSE you can specify multiple columns if the row is indetified using more than one field)

delete from MASTER where identity_col not in ( select Min(identity_col) from MASTER group by trnx_uid);

Advertisement

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