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...


how to delete duplicate rows in sql server2005

Answers were Sorted based on User's Feedback



how to delete duplicate rows in sql server2005..

Answer / pritesh

By using temporary table, But it will delete exactly
duplicate rows NOT RECOMMANDABLE FOR HUGE TABLE. Query will
be.

SELECT DISTINCT * INTO #A FROM TABLE1

TRUNCATE TABLE TABLE1

INSERT INTO TABLE1
SELECT * FROM #A

Is This Answer Correct ?    30 Yes 3 No

how to delete duplicate rows in sql server2005..

Answer / arunkumar_mlx

WITH A
AS
(
SELECT ROW_NUMBER() OVER ( PARTITION BY
columnname_1,columnname_2 ORDER BY columnname_1) AS
duplicate FROM table_name
)
SELECT * FROM A WHERE duplicate>1
--DELETE FROM A WHERE duplicate>1

First select and you can find the row_number having more
than 1 rows.

Then delete them on comment of select stmt inside the
query..
decomment of that delete stmt will delete the duplicate
rows.

Is This Answer Correct ?    8 Yes 4 No

how to delete duplicate rows in sql server2005..

Answer / enis ertem

with DeleteDups as
(
Select * from TableA AS T1
where KeyCol <
(Select Max(Keycol) from TableA as T2
where t1.Id = T2.ID)
)

Delete from Delete Dups;

Is This Answer Correct ?    4 Yes 1 No

how to delete duplicate rows in sql server2005..

Answer / nittu

Delete from Tbl where Id NOT IN(
select Min(Id)
from tbl
Group By Colmn1,Column2)

Is This Answer Correct ?    0 Yes 0 No

how to delete duplicate rows in sql server2005..

Answer / surendra pal singh

delete from tablename where empname in (select empname from table name group by empname having empid>1)

where empname and empid are the columns of the table.
definately it will work

Is This Answer Correct ?    0 Yes 0 No

how to delete duplicate rows in sql server2005..

Answer / apps

select distinct eno,ename into temp_table from main_table
drop table main_table
-----
sp_rename temp_table,main_table

Is This Answer Correct ?    0 Yes 1 No

how to delete duplicate rows in sql server2005..

Answer / sundaravadivel g

Select top 1 * from table where a=1

select top 1* into table1 from table where a=1

delete from table

insert into table
select * from table1

Is This Answer Correct ?    1 Yes 7 No

Post New Answer

More SQL Server Interview Questions

What is the purpose of data source?

0 Answers  


Do you know what is difference between index seek vs. Index scan?

0 Answers  


What is table value parameters (tvp)?

0 Answers  


How do you delete a data source?

0 Answers  


How can I know what query is executing by by a particural user? (using sp id or any othe way.)

2 Answers  


Can a unique index be created on a column, which contains null?

0 Answers  


please give me query code of unique fuction select UNIQUE (name) from emp_info Incorrect syntax near the keyword 'UNIQUE'.

1 Answers   TCS,


Do you know what is sql injection?

0 Answers  


How to create an multi-statement table-valued function?

0 Answers  


What is the New in SQL server 2008?

0 Answers  


What is the use of stored procedure?

0 Answers  


If any possiable to use 2 primary key in single table? How many primary key & foreign key used in each table(min & max)?

3 Answers  


Categories