SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a plain list (not a document library) in SharePoint 2007 that has a lot of list item versions. I'd like to loop through the list items and programmatically delete the old versions. I am doing this with the following psuedo code:

theList = web.Lists["TheList"]
items = theList.Items
for item in items:
    versions = item.Versions

The call to DeleteAll() takes quite a bit of time espacially for the items with a lot of versions so it makes me think it doing its job. But with that said, after running the code the AllDocVersion table in the content database has neither decreased in size nor has it fewer items in it. More concerning is that when I programmatically inspect the versions of list items in the list, they show that they have no versions for me to delete. This makes me think there is now a bunch of orphaned items in the content database although the stsadm -o databaserepair command doesn't show any orphans.

With that said, what is the proper course of action to get this corrected?

share|improve this question
When you delete the items are they moved to the recycle bin? – shufler Dec 11 '12 at 5:17
They are not in the recycle bin...that's accomplished via the RecycleAll() method – Mark Mascolino Dec 11 '12 at 21:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.