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

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

958


When do you think a developer should use sql server-based cursors?

1035


Define cross join in sql server joins?

1010


What are the options which must be set to allow the usage of optimistic models?

951


How to use column default values in insert statements in ms sql server?

1019


What are advantages of ssrs or why we should use ssrs?

137


What is explicit cursors?

1057


Where sql server usernames and passwords are stored in a sql server?

977


How to handle error or exception in sql?

971


Do you think BCNF is better than 2NF & 3NF? Why?

1265


Does partitioning help performance?

926


How to Update from select query in sql server?

1046


What is the difference between varchar and varchar(max) datatypes?

1054


explain different types of joins? : Sql server database administration

968


Explain the database you used in your final year project?

1026