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 |
sharepoint10
Starting Member
2 Posts |
Posted - 2011-04-07 : 11:18:23
|
Hi - I have a table "docversion". "docversion" has a field called "version". "version" can be anything from 1 to 1000, how do I write a delete query which will delete the oldest versions, apart from the last 10. i.e if there are 80 versions I want version 70 to 80 to remain. Thanks! |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-04-07 : 11:25:32
|
If this gives what you want to delete, select * from table where docversion<(select max(docversion)-10 from table)then rundelete from table where docversion<(select max(docversion)-10 from table)MadhivananFailing to plan is Planning to fail |
|
|
sharepoint10
Starting Member
2 Posts |
Posted - 2011-04-08 : 05:03:06
|
Thanks! |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-04-12 : 09:35:56
|
You are welcomeMadhivananFailing to plan is Planning to fail |
|
|
|
|
|