if 3 duplicate records in a table,i want to delete 2 duplicate
records by keeping 1 duplicate and 1 original as it is,how?
Answer Posted / mohamed zunu
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')
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 ? | 9 Yes | 1 No |
Post New Answer View All Answers
What are the mathematical functions supported by sql server 2005?
How to update values in a table with update statements in ms sql server?
How can you list all the table constraints in a database?
Detail about the hardware which is supported by SQL server?
Why I am getting this error when dropping a database in ms sql server?
What to perform pattern match with the like operator?
Do you know what are the restrictions that views have to follow?
What is scheduled job and how to create it?
Explain different backup plans?
How to write the storeprocedure with in the store procedure? and how can we write the store procedure with in a trigger vice versa? plz post me the exact answer?
What are the underflow and overflow behaviors on float literals?
Difference between connected and disconnected database in .net with sql server?
wat wil hapn if we give the both read and deny read permission to user?
Why use cursor in sql server?
Will count(column) include columns with null values in its count?