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
What is a coalesce function?
What is sql or structured query language?
What is clustered index
What are wait types?
What is the difference between upgrade and migration in sql server?
Is there any performance difference between if exists (select null from table) and if exists (select 1 from table)?
How do I start sql server 2017?
Why and when do stored procedure recompile?
What are the different SQL Server Versions you have worked on?
Is it possible to have clustered index on separate drive from original table location?
What are the pros and cons of putting a scalar function in a queries select list or in the where clause?
Can you index views?
How to connect php with different port numbers?
Why we use the openxml clause?
Explain “row_number()” in sql server with an example?