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
let's assume you have data that resides on sql server 6.5. You have to move it sql server 7.0. How are you going to do it? : Sql server database administration
role of sql sever 2005 in database rather than any other database
Is truncate a dml command?
What is the difference between clustered and non-clustered indexes in ms sql server?
Explain the difference between function and stored procedure?
What are trace flags and mention a few common trace flags used with sql server?
What command would you use to add a column to a table in sql server?
What is failover clustering overview?
Can sql servers link to other servers?
What is the recommended total size of your memory optimized tables?
What is the maximum length of an alert name?
How to use go command in "sqlcmd"?
What is xml datatype?
Write an SQL query to obtain the 2nd highest salary.
explain different types of constraints? : Sql server database administration