How to delete the duplicate rows from a table in SQL Server ??
Answers were Sorted based on User's Feedback
Answer / vnreddy
create table sampletbl(id int,name varchar(100))
insert into sampletbl values(1,'aa')
insert into sampletbl values(1,'aa')
insert into sampletbl values(1,'aa')
insert into sampletbl values(2,'bb')
insert into sampletbl values(2,'bb')
with cte as(
select ROW_NUMBER() over (partition by id order by id) as r_no,* from sampletbl)
delete from cte where r_no>1
select * from sampletbl
Is This Answer Correct ? | 10 Yes | 2 No |
Answer / sudha511
select distinct * into #temp from sampletbl
delete sampletbl
insert into sampletbl
select * from #temp
drop table #temp
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / himmat
delete from table name
having count(column name)>1
group by column name
Is This Answer Correct ? | 15 Yes | 25 No |
What is awe?
What is sql server profiler?
What is a primary index?
What is 1nf 2nf and 3nf?
What are types of subqueries?
How to create prepared statements using odbc_prepare()?
What is amo? : sql server analysis services, ssas
What is Schema? and why we use schemas?
What is the process of indexing?
Tell me what is normalization? Explain different forms of normalization?
Define primary key?
How do I start sql server 2016?