Recently One of the friend ask how we can find duplicate rows in SQL server so I said there are various way of finding duplicates and then I show him few ways of findings duplicate based on criteria. I thought it is a very basic question and still lots of people does not know how to find duplicate rows in SQL Server. So it is good idea to write blog post about it. In this blog post I’m going to explain the same various way of finding duplicates.
First all, We need a table to find duplicate rows. So following is a table for that.I have created Employee table with four fields.
CREATE TABLE [dbo].[Employee]( [Id] [int] NOT NULL, [FirstName] nvarchar NULL, [LastName] nvarchar NULL, [Designation] nvarchar NULL ) ON [PRIMARY]
Now once you create this “Employee” table now it’s time to write insert data. I have inserted following data.