SharePoint 2010: Content Database not upgraded


Problem: Every time customer would run Upgrade-SPContentDatabase on a specific Content Database it would fail. The database was stuck in a compatibility mode since it could not be upgraded to the build version of the rest of the farm.

Troubleshooting:

  • Looked at upgrade logs and found the error 'Field name already exists'. Lucky for us, this content database only has one site collection within it.
  • I also noticed something in the logs that referenced a Workflow Content Type
  • Used this nifty powershell script to identify the list that has a duplicate field in it. This script will loop through all sites and their tasks lists, then identify which has the problem:

    $SiteURL = http://mySitecollection

    param(
    [string]$SiteURL
    )

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | out-null
$site = new-object Microsoft.SharePoint.SPSite($SiteURL)

#Loop over all webs
foreach($web in $site.AllWebs)
{
 Write-Host "Checking Web: "$web.URL
 
 #Loop over the lists
 foreach($list in $web.Lists)
 {
  #Only continue on Task lists
  if($list.BaseTemplate -eq "Tasks")
  {
   #Loop over content types
   foreach($ct in $list.ContentTypes)
   {
    $isWFCT = $ct.Id.IsChildOf([Microsoft.SharePoint.SPBuiltInContentTypeID]::WorkflowTask)
   
    if($isWFCT -eq $true)
    {
     Write-Host "   Found Workflow Content Type: "
     Write-Host "     List:  "$list.Title
     Write-Host "     CType: "$ct.Name
    
     try
     {
      $field = $list.Fields[[Microsoft.SharePoint.SPBuiltInFieldId]::WorkflowInstanceID]
     }
     catch
     {
      Write-Host "------ERROR WITH WorkflowInstanceID------" -ForegroundColor Red
     }

     try
     {
      $field = $list.Fields[[Microsoft.SharePoint.SPBuiltInFieldId]::GUID]
     }
     catch
     {
      Write-Host "------ERROR WITH GUID------" -ForegroundColor Red
     }

    }
   }
  }
 }
 
 $web.Dispose()
}

  • the output looks something like this:

Checking
Web:  http://site1

Checking
Web:  http://site2

   Found Workflow Content Type:

     List:  My Tasks List Items

     CType: Workflow Task

  • Now the strange thing was when I went to that list, I did not see any duplicate fields in list settings. But I did see a duplicate reference in their views, in this case, it was the 'Priority' field
  • customer then made those fields appear in the views to see if there is any data in them. In this case there was not, so they decided to delete one of them.

Cause: This site collection was once a Project Server 2007 site that was migrated to sharePoint 2010. My guess is that this caused some corruption when the site was brought over.

Resolution: Downloaded SharePoint Manager for 2010: http://spm.codeplex.com/downloads/get/526736. This is a great tool that will allow you to view the entire structure (including lists and their fields) of a site in a tree-like structure. You have to install this tool on one of your sharepoint servers. We were able to see the duplicate field that the customer had identified to delete and deleted it via this tool. Re-ran Upgrade-SPContentDatabase successfully.

Fight Comparison: Holyfield vs. George Foreman. Foreman was stubborn, he wouldn't go down. But Holyfield's persistence paid off in the end, just as mine did.

Comments (0)

Skip to main content