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 start and end transact-sql statements?
What is model database? : SQL Server Architecture
Are semicolons required at the end of sql statements in sql server 2005?
How do I get Report Builder to generate a parameter that can be set by users viewing the report?
what is package and it uses and how can u call a package
How to count groups returned with the group by clause in ms sql server?
Explain what is the purpose of sql profiler in sql server?
Can we check locks in database? If so, how can we do this lock check?
How do you Implement SSIS Packages in your Project?
What is an etl file?
What is the difference between composite index and covering index?
When should you use an instead of trigger?
Do you know what are pages and extents? : SQL Server Architecture
How do I create a partition table in sql server?
What are the differences between local and global temporary tables?