Write a query to delete duplicate records in SQL SERVER
Answer Posted / rama krishna
This will help u a lot bcz dynamically it will delete
duplicates
create table tbl1 (col1 int)
insert into tbl1 values(1)
insert into tbl1 values(1)
insert into tbl1 values(1)
insert into tbl1 values(2)
insert into tbl1 values(2)
insert into tbl1 values(2)
insert into tbl1 values(2)
insert into tbl1 values(3)
insert into tbl1 values(3)
select * from tb1
set rowcount 1
select 'start'
while @@rowcount > 0
delete a from tbl1 a where (select count(*) from tbl1 b
where a.col1 = b.col1)>1
set rowcount 0
select * from tbl1
set nocount off
| Is This Answer Correct ? | 23 Yes | 9 No |
Post New Answer View All Answers
How to use subqueries with the exists operators in ms sql server?
What is the library index called?
Explain “@@rowcount” and “@@error” in sql server?
Describe the functionalities that views support.
How you provide security to cube? : sql server analysis services, ssas
What are the differences between web role and worker role?
How you can change the database name in SQL SERVER?
What are the 10 characteristics of data quality?
Explain about builtinadministrator?
Can the “if update (colname)” statement be used in a delete trigger?
Explain different types of collation sensitivity?
Explain about thread and memory management process of SQL?
How do I partition a table in sql server?
What part does database design plays a role in performance of an sql server-based application?
How to list all triggers in the database with sys.triggers in ms sql server?