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 |
|
vgr.raju
Yak Posting Veteran
95 Posts |
Posted - 2006-08-04 : 20:49:38
|
| Hello Experts, If some one please point me how to delete the rows based on the row numbers.Currently I am using two work tables and then inserting the rownumber values and then deleting.Takes some extra work.I used the rownumber function to delete.But it gives the Error.DELETE WORKTABLE WORKTABLEwhere ROW_NUMBER()OVER(ORDER BY RAND()) in (1,2,3) Msg 4108, Level 15, State 1, Line 1Windowed functions can only appear in the SELECT or ORDER BY clauses.I would really appreciate the Help!Thanks!Raju |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-08-04 : 20:58:46
|
| DELETE WORKTABLEfrom WORKTABLE wjoin (select pk, rownum = ROW_NUMBER()OVER(ORDER BY RAND()) from WORKTABLE) aon a.pk = w.pkwhere a.rownum in (1,2,3) Of course this will always delete the same rows - rand() doesn't do anything.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
vgr.raju
Yak Posting Veteran
95 Posts |
Posted - 2006-08-04 : 21:48:07
|
| It did the Trick.Thanks! |
 |
|
|
|
|
|