Write a query to delete duplicate records in SQL SERVER
Answer Posted / sagun sawant
Name Age
chandran 23
ranjith 24
chandran 23
To delete one of the duplicate records use following query
(For sql server 2000)
Set rowcount 1
delete from [tableName] order by name
set rowcount 0
--Write a cursor to delete multiple duplicate records
Or (In sql server 2005)
;with DelDup as (select row_number() over (partition by
sname order by sname) as RONO ,sname from [TableName])
Delete from DelDup where RONO > 1
| Is This Answer Correct ? | 29 Yes | 11 No |
Post New Answer View All Answers
How to use subqueries with the in operators in ms sql server?
Explain few of the new features of sql server 2008 management studio
What are the advantages of sql stored procedure?
how would you troubleshoot blocking? : Sql server database administration
How to write an inner join with the where clause in ms sql server?
What is the purpose of sql profiler in sql server? : sql server database administration
Can You Use A Stored Procedure To Provide Data To An Ssrs Report?
What is a matrix in ssrs?
Do you have any idea about the tcl commands?
How to view the error log for any specific instance? : sql server database administration
Describe how to use the linked server?
How to sort the query output with order by clauses in ms sql server?
What are the advantages of using cte?
How to store and query spatial data?
What are the advantages to use stored procedures?