Copy Missing Objects From One Content Database to Another

I recently applied a cumulative update to a SharePoint environment that hadn’t been patched in years. When I tried to upgrade the main production content database, the process failed and rendered the site inaccessible. The errors logs mentioned invalid objects such as “Webs” and “Sites”, and upon further troubleshooting we learned that because of permission issues, the content database was missing critical views and procedures due to one of the updates rolled up into the cumulative update.

NOTE: I’d like to take a moment to stress the importance of backups. CONFIRM THAT YOU HAVE A HEALTHY BACKUP BEFORE PERFORMING MAINTENANCE. EVERY. SINGLE. TIME! Thank you.

Even though we corrected the permission issues, no matter what we tried we could not re-run the upgrade to fix the problem. Instead, we had to copy those missing objects and views from the sandbox content database to prod, and cross our fingers it would work. (spoiler: it did)

  1. Right click your healthy database > Tasks > Generate Scripts…
  2. In the Choose Objects prompt, select the objects you would like to copy. In our case we copied Views and Stored Procedures.
  3. Click Next
  4. Select “Save to new query window”
  5. Next > Next > Finish
  6. Change the database in the query to the database that’s missing objects
  7. Execute
  8. Browse the site to confirm content
  9. Drink

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s