Prepare for your Next Interview
This is a discussion on How can we delete the duplicate data from a database table? within the SQL Server forums, part of the Databases category; To delete the duplicate data we may use the temporory tables, but with out using any teporory tables can we delete the duplicated data, if how it is possible?...
|
|||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
|||
|
To delete the duplicate data we may use the temporory tables, but with out using any teporory tables can we delete the duplicated data, if how it is possible?
Last edited by nageshkota : 04-23-2008 at 09:14 AM. |
| The Following 2 Users Say Thank You to nageshkota For This Useful Post: | ||
| Sponsored Links |
|
|||
|
Re: How can we delete the duplicate data from a database table?
;with DelDup as (select row_number() over (partition by
ID order by ID) as RowNo from duplicateTest ) Delete from DelDup where RowNo> 1 |
| The Following User Says Thank You to RajneshBansal For This Useful Post: | ||
|
|||
|
Re: How can we delete the duplicate data from a database table?
To delete the duplicate data you can use this sql query: method 1 :delete from categories where categories.id not in (select min(c.id) from categories as c where categories.category_name = c.category_name) method 2: set rowcount syntax for set rowcount is as follows: set rowcount { number | @number_var } set rowcount 3 delete from users where firstname = n'elvis' and lastname = n'presley' set rowcount 0 -- (3 row(s) affected)
|
|
|||
|
Re: How can we delete the duplicate data from a database table?
Quote:
WHERE wiki_id in (SELECT wiki_id FROM wikis_details GROUP BY wiki_id HAVING count(wiki_id)>1) |
|
|||
|
Re: How can we delete the duplicate data from a database table?
We can use Common table Expression
;With empcte(id,sal,Ranking) as (Select id,sal,Ranking=Dense_Rank() over (Partition by id,sal order by newid() asc) from employee) Delete * from empcte where Ranking>1 Regards Smitha |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Delete duplicate record | raghvendra_rai | SQL Server | 15 | 03-20-2008 10:29 PM |
| How to delete duplicate rows in a table | saritha_racharla | SQL | 6 | 11-21-2007 01:48 AM |
| How can I compare the data table values with Database | sanathsharma | QTP | 0 | 07-12-2007 05:33 AM |
| Delete duplicate records without using "rowid" | Geek_Guest | SQL | 7 | 07-12-2007 03:06 AM |
| I want load the duplicate records to seperate table | Geek_Guest | Data Warehousing | 4 | 04-06-2007 02:10 AM |