Removing Duplicate Row from a Table in SQL Server

--create a table (here I have a table temp table)

Declare @employee table(ID int ,name varchar(10), salary money)

--insert the values

insert into @employee(id,name,salary)values(1,'ashok' ,20000),(1,'ashok',20000) , (2,'sejal',15000) , (3,'vinod',56985)

--view the table values
select
* from @employee

you get output:

ID name salary
1 ashok 20000.00
1 ashok 20000.00
2 sejal 15000.00
3 vinod 56985.00

Here, you can see that there's one row that is appearing twice.

So, our target is to delete any one of them. To do so, write the following Query.

delete top (1) from

@employee
where
id in
(

select
id from @employee
group
by id ,name, salary
having
count(*)>1
)
 
Note: Remember one thing write all the column in group by 

Run and see:

-- select * from @employee