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 … Continue reading Delete Duplicate Rows SQL Server

Advertisements

Find Duplicate Records in SQL Server

Microsoft SQL Server tables should never contain duplicate rows, nor non-unique primary keys. For brevity, we will sometimes refer to primary keys as "key" or "PK" in this article, but this will always denote "primary key." Duplicate PKs are a violation of entity integrity, and should be disallowed in a relational system. SQL Server has … Continue reading Find Duplicate Records in SQL Server