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
Describe and explain about SQL native client?
Why truncate is ddl command?
How to verify the port number of the sql server?
What is the default server name for sql server?
Explain “not null constraint” in sql server?
What are the restrictions that views have to follow? : SQL Server Architecture
What are the types of lock supported by ?
Can we use max in where clause?
What is tablix?
What is the use of @@spid?
How do you know if sql server is running on your local system?
How to use subqueries with the exists operators in ms sql server?
How can delete duplicate records in cte in sql server?
Why SQL Agent is used?
Can we call future method from trigger?