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
What is sqlcmd?
Find nth lowest salary or get nth lowest salary?
What is bcnf normalization form?
What do you mean by an execution plan?
What are the main sources of data?
In one interview...interviewer ask me question pleas tell me sql server architecture.. can any body tell me the sql server architecture with digram
What is the difference between cube operator and rollup operator? : SQL Server Architecture
Explain transaction server isolation?
Can you pass expressions to stored procedure parameters?
What are differences in between sql server 2012 and sql server 2016?
How to create view in stored procedure sql server?
Can I run multiple instances of sql server 2000 at the same time on one computer?
If no size is defined while creating the database, what size will the database have?
What are logical database components? : SQL Server Architecture
How you can minimize the deadlock situation?