Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ranjeetsingh_6
Posting Yak Master
125 Posts |
Posted - 2009-02-27 : 03:40:42
|
| Hi,I was attend a interview at last week and face a question thatHow duplicate records will deleted from a table and not use likethis approach to Eliminate the duplicate records into SELECT DISTINCT into a temporary table, truncate the original table and SELECT the records back into the original table.which are mention at link http://www.sqlteam.com/article/deleting-duplicate-recordsNote:- Interviewer does not want way like above linkHe want delete duplicate records without use of any temprory table.Ranjeet Kumar Singh |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-02-27 : 03:45:32
|
| Try this once,delete t from( select row_number() over ( partition by col order by col ) as rn from urtable) twhere t.rn > 1 |
 |
|
|
ranjeetsingh_6
Posting Yak Master
125 Posts |
Posted - 2009-02-27 : 03:54:29
|
| Thanks a lot.................Ranjeet Kumar Singh |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-27 : 03:56:34
|
| see this link to delete the duplicate records by cte& row_nuber functionshttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=120411 |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-02-27 : 03:58:21
|
quote: Originally posted by ranjeetsingh_6 Thanks a lot.................Ranjeet Kumar Singh
Welcome |
 |
|
|
|
|
|