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

we innadvertantly had versioning enabled on a heavily used list and the database table "alldocsversions" has grown to 225 Gb. Can anyone suggest a way in which we can rid ourselves of the previous versions and thus shrink the size of the database

share|improve this question

Darko Milevski has a post on this exact issue:

He uses the following script to remove the versions.

$snap = Get-PSSnapin | Where-Object {$_.Name -eq ‘Microsoft.SharePoint.Powershell’}
if ($snap -eq $null) {
Add-PSSnapin Microsoft.SharePoint.Powershell
#Set site url ‘http://<servername>/site’. ‘sps2010’ is my test sharepoint server
$siteurl = “http://sps2010/test”
#Document Library Name. ‘VersionsTestDL’ is my test document library
$dlname = "VersionsTestDL"

#get site obj
$site=new-object Microsoft.SharePoint.SPSite($siteurl)
#open root web
$web = $site.OpenWeb()
#get doclib
$dl = $web.Lists[$dlname]

foreach ($doc in $dl.Items)
  #Delete All Versions
  $versions = [Microsoft.SharePoint.SPListItemVersionCollection]$doc.Versions
  #If you want to move them to Recycle Bin only  and not to delete them forever, use RecycleAll() method 


Just as Darko has done, you should test your scripts out before running in production (and I would recommend after a backup)

Due note that to "reclaim" that space you will have to shrink your database, and probably will want to defrag it afterwards. you can review the DB Maintenance white paper from MS here covering both:

This should not cause you any issues with specific SBS integrated tools.

share|improve this answer
Jesus thanks that is great, it does however say that the powershell script os for sharepoint 2010 which is later than the version that ships with sbs2008. However, we will trya it and report back – Andrew Rosamond Nov 2 '11 at 16:56

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.