How to delete the duplicate rows from a table in SQL Server ??
Answer Posted / 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 |
Post New Answer View All Answers
What are the results of running this script?
What do you understand by user-defined function in the sql server?
Mention the differences between substr and charindex in sql server.
What is the query and subquery?
What is single-user mode and what are the steps you should follow to start sql server in single-user mode?
What are the character string functions supported by sql server 2005?
Tell me what are the essential components of sql server service broker?
What is temporal data type?
Mention what are the different types of ssrs reports?
What is explicit cursors?
Where do we use trace frag?
How do you delete duplicate records in sql server?
Create and insert into temp table in sql server?
Explain activity monitors
What are different types of collation sensitivity?