Write a query to delete duplicate records in SQL SERVER
Answer Posted / senthilsjc
This query delete duplicate records(but not delete both
duplicate)
set rowcount 1
delete yourtable
from yourtable a
where (select count(*) from yourtable b where b.name=a.name
and b.age=a.age)>1
while @@rowcount >0
delete yourtable
from yourtable a
where(select count(*) from yourtable b b.name=a.name and
b.age=a.age)>1
set rowcount 0
| Is This Answer Correct ? | 6 Yes | 12 No |
Post New Answer View All Answers
What are views in ms sql server?
how do you test proper tcp/ip configuration windows machine? : Sql server database administration
Explain what is scheduled job and how to create it?
Can we write trigger for view?
Why should one not prefix user stored procedures with ‘sp_’?
How to create a simple stored procedure in ms sql server?
What are functions in the sql server?
What are the 2 types of classifications of constraints in the sql server?
When setting replication, is it possible to have a publisher as 64 bit sql server and distributor or subscribers as a 32 bit sql server?
Can you create a logon trigger in sql server 2005 express edition?
What is the difference between implicit and explicit transaction?
What is the syntax to execute the sys.dm_db_missing_index_details? : sql server database administration
What are scheduled tasks in sql server?
What are the new features in sql server 2016?
What is user-defined functions? What are the types of user-defined functions that can be created?