Wednesday, 16 March 2016

How to delete duplicate data from table

 firstly create a table named tbl_Employee_DuplicateRow by the script given below.


CREATE TABLE tbl_Employee_DuplicateRow
(
      EmpID int primary key IDENTITY(1,1) NOT NULL,
      DepartmentID int,
      EmpName nvarchar(50) NULL,
      Salary int NULL,

)

 Once table is created after insert the data into the table by the script given below.
insert into tbl_Employee_DuplicateRow(DepartmentID,EmpName,Salary)values('1','Sudhir',10000);
insert into tbl_Employee_DuplicateRow(DepartmentID,EmpName,Salary)values('2','Mark',15000);
insert into tbl_Employee_DuplicateRow(DepartmentID,EmpName,Salary)values('3','Alinaa',23000);
insert into tbl_Employee_DuplicateRow(DepartmentID,EmpName,Salary)values('4','Rajesh',1000);
insert into tbl_Employee_DuplicateRow(DepartmentID,EmpName,Salary)values('5','Daniel',17000);
insert into tbl_Employee_DuplicateRow(DepartmentID,EmpName,Salary)values('6','Micheal',30000);
insert into tbl_Employee_DuplicateRow(DepartmentID,EmpName,Salary)values('7','Ricky',10400);
insert into tbl_Employee_DuplicateRow(DepartmentID,EmpName,Salary)values('8','Amit',80000);
insert into tbl_Employee_DuplicateRow(DepartmentID,EmpName,Salary)values('9','Richard',9000);


Execute the query and check the table...



No comments:

Post a Comment