Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

How to use subqueries with the exists operators in ms sql server?

1119


What is the library index called?

1059


Explain “@@rowcount” and “@@error” in sql server?

1092


Describe the functionalities that views support.

1100


How you provide security to cube? : sql server analysis services, ssas

965


What are the differences between web role and worker role?

122


How you can change the database name in SQL SERVER?

1192


What are the 10 characteristics of data quality?

956


Explain about builtinadministrator?

1055


Can the “if update (colname)” statement be used in a delete trigger?

991


Explain different types of collation sensitivity?

982


Explain about thread and memory management process of SQL?

973


How do I partition a table in sql server?

1042


What part does database design plays a role in performance of an sql server-based application?

986


How to list all triggers in the database with sys.triggers in ms sql server?

1083