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
If you're given a raw data table, how would perform etl (extract, transform, load) with sql to obtain the data in a desired format?
What are the different subsets of sql?
Is there any performance difference between if exists (select null from table) and if exists (select 1 from table)?
Explain “row_number()” in sql server with an example?
How do I start sql server 2017?
What are the different types of subquery?
Can we make the the chages By Using the Sql if u know any function or process please inform me Actuall result: BRK1 Break 1 Part 1 00:01:00:00 60 BRK1 Break 1 Part 2 00:01:00:00 60 BRK2 Break 2 Part 1 00:01:00:00 60 BRK2 Break 2 Part 2 00:01:00:00 60 BRK2 Break 2 Part 3 00:01:00:00 60 BRK3 Break 3 Part 1 00:01:00:00 60 BRK3 Break 3 Part 2 00:01:00:00 60 Desired O/P: BRK1 Break 1 Part 1 00:01:00:00 60 Part 2 00:01:00:00 60 BRK2 Break 2 Part 1 00:01:00:00 60 Part 2 00:01:00:00 60 Part 3 00:01:00:00 60
How to convert numeric expression data types using the cast() function?
What are the risks of storing a hibernate-managed object in a cache? How do you overcome the problems?
What is an indexed view?
List out the different types of locks available in sql server?
How can we solve concurrency problems?
What kind of problems occurs if we do not implement proper locking strategy?
What is a coalesce function?
Can one drop a column from a table?