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 send a ssrs report from ssis?
What is cte (common table expression)?
Give some Scenario for Non Clusterd index? Can we write system defined functions in side The Function? Wat is the Unique Datatype?
How to create a scrollable cursor with the scroll option?
What is SQL Azure Fabric?
What are constraints in microsoft sql server?
Describe in brief authentication modes in sql server.
How raid can influence database performance?
How to update a field in SQL after ALTERING a row?
What is use of attribute hierarchy ordered ? : sql server analysis services, ssas
Does sql server 2000 clustering support load balancing?
Tell me what are cursors and when they are useful?
What is built-in function?
What is the current limitation of the size of SQL Azure DB?
as a general practice, it is recommended to have dbo be the owner of all database objects however, in your database you find number of tables owned by a user other than dbo, how could you fix this? : Sql server administration