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 |
|
cognos
Starting Member
10 Posts |
Posted - 2011-06-16 : 04:19:01
|
| i am deleting duplicate rows in table delete from Test A where A.rowid > (select min(B.rowid) from Test B where A.id = B.id)DELETE FROM TestWHERE rowid NOT IN (SELECT max(rowid) FROM Test GROUP BY id HAVING count(*)>=1)when i was executing these first one Incorrect syntax near 'A' error coming and executing second one also row id error coming.please can you any one help me in thisddd |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-06-16 : 04:20:53
|
Are you on SQL Server 2005 or above? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
cognos
Starting Member
10 Posts |
Posted - 2011-06-16 : 05:03:16
|
| sqlserver 2008ddd |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-06-16 : 05:29:53
|
Test this please:delete dtfrom(selectrow_number() over (partition by id order by rowid asc) as rownum,*)dtwhere rownum > 1If it is not working then please give table structure, sample data and wanted result. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
cognos
Starting Member
10 Posts |
Posted - 2011-06-16 : 05:37:14
|
| id name city1 john usa1 john usa2 peter ukif table is like this i want to delete dupicate rows means 1 john usa1 john usa how can do this?ddd |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-06-16 : 05:40:14
|
delete dtfrom(selectrow_number() over (partition by id order by name asc) as rownum,*from HereComesYourTableName)dtwhere rownum > 1 No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|