CREATE TABLE dbo.Employee
(
EmpID int IDENTITY(1,1) NOT NULL,
Name varchar(55) NULL,
Salary decimal(10, 2) NULL,
Designation varchar(20) NULL
)
insert Employee values('Amit',12000,'SE')
insert Employee values('Mohan',15000,'SE')
insert Employee values('Monu',27000,'SSE')
insert Employee values('Riyaz',16000,'SE')
insert into Employee
select Name,Salary,Designation from Employee
select * from Employee
with tmpEmp (Name,DuplicateRowCount)
as
(
select Name,row_number() over(partition by Name,Salary order by name) as DuplicateRowCount
from Employee
)
delete from tmpEmp where DuplicateRowCount>1
select * from Employee
(
EmpID int IDENTITY(1,1) NOT NULL,
Name varchar(55) NULL,
Salary decimal(10, 2) NULL,
Designation varchar(20) NULL
)
insert Employee values('Amit',12000,'SE')
insert Employee values('Mohan',15000,'SE')
insert Employee values('Monu',27000,'SSE')
insert Employee values('Riyaz',16000,'SE')
insert into Employee
select Name,Salary,Designation from Employee
select * from Employee
with tmpEmp (Name,DuplicateRowCount)
as
(
select Name,row_number() over(partition by Name,Salary order by name) as DuplicateRowCount
from Employee
)
delete from tmpEmp where DuplicateRowCount>1
select * from Employee
No comments:
Post a Comment