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 the use of partition by in sql server?
Are connections to sql server encrypted?
How check triggers in sql server?
What is difference between delete & truncate commands?
what's sql server? : Sql server database administration
What is an indexed view?
Does partitioning help performance?
What is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure? How many levels of sp nesting is possible?
Write the syntax for stuff function in an sql server?
Explain the difference between functions and stored procedures in sql server?
Describe the functionalities that views support.
What are the underflow and overflow behaviors on float literals?
What do you mean by sql server 2005 express management tools?
To automatically record the time on which the data was modified in a table, which data type should you choose for the column?
What are the basic features of a trigger in ms sql server?