Tuesday, May 24, 2011

How to remove the GUIDs from the SharePoint search service application databases

For this post I created a Search service application call Blog Search Service App using Central Administration. After it completed I was stuck with the following three databases with those unnecessary GUIDs stapled on the end.

Renaming the Crawl Store database

  1. In Central Admin go to manage service applications
  2. Click on your Search service application
  3. Scroll down the page and click on modify under Search Application Topology
  4. Under Databases click on your Crawl Database and from the drop down click Edit properties
  5. Find the database name and simply highlight the GUID and hit delete
  6. Click OK

When you return to the manage topology screen you will see pending update. The change will not be committed until you click the Apply Topology Changes button at the bottom of the screen. Don't do it yet though, lets rescue another GUID first.

Renaming the Property database

  1. Assuming you are still on the same page from the last step
  2. Under Databases click on your Property Database and from the drop down click Edit properties
  3. Find the database name and simply highlight the GUID and hit delete
  4. Click OK

Now all that is left is to scroll to the bottom of the page and click Apply Topology Changes. This will probably take a couple of minutes to run. So just kick back for a moment and think of what better planet you left for the children by saving these two GUIDs. It may take a while to run depending on the state of your databases. Mine took about 6 minutes on empty database for my VM.

Here is a screen shot of the results. That was really pretty painless too bad the next one is not.

Renaming the Admin database

Put on your big boy pants because this one is going to require some ninja like SQL and PowerShell skills. (Or I guess you can just cut and paste what I have here.)

  1. On your SQL Server open SQL Server Management Studio
  2. Find your Search admin database. From the screen shot mine was named Blog_Search_Service_App_DB_fe289c49b61344b48952a546e48e0135. Right click on it on the database and select Tasks > back up…
  3. Back the database up. If you are unsure how to do this the defaults should work fine so click OK.
  4. At the backup successful message click OK
  5. Scroll up to Databases, right click and select Restore Database…

  6. Click the radio button for From device: and the click the … button to the right.

  7. Click Add
  8. Now select the backup file you just created. If you just clicked OK on the backup screen SQL should open right to the file for you. Once you find it click OK.
  9. Click OK on Specify Backup
  10. Check the box under Restore next to your backup
  11. Now look toward the top of the window and enter your new database name in the To database field. For the example I entered Blog_Search_Service_App_DB. Double check yourself in the screen shot below.

  12. Click OK
  13. At the successful screen click OK

The SQL hard work is over but don't close management studio quite yet. You will need to come back to delete the old database in a little bit.

  1. Now go back over to your SharePoint server
  2. Open the SharePoint Management Shell by clicking Start > All Programs > Microsoft SharePoint 2010 Products > SharePoint 2010 Management Shell
  3. Now enter the following line of PowerShell remembering to change the identity to your service application name:

    $searchapp = Get-SPEnterpriseSearchServiceApplication -identity "Blog Search Service App"

  4. Now enter the following line of PowerShell (it might take a minute to run):


  5. Now enter the following line of PowerShell remembering to update your database name and database server:

    $searchapp | Set-SPEnterpriseSearchServiceApplication -DatabaseName "Blog_Search_Service_App_DB" –DatabaseServer "2010server"

  6. Now enter the following line of PowerShell:


  7. Double check yourself in the screenshot below.

  8. Now before you continue you need to make sure the database change is complete. The best way to do this I believe is to use this PowerShell:

    Do {write-host -NoNewline .;Sleep 10; $searchInstance = Get-SPEnterpriseSearchServiceInstance -Local} while ($searchInstance.Status -ne "Online")

This will display a . every 10 seconds until all of the search components return to an online state. It might take a few minutes but be patient.

Now jump back over to the SQL Server to delete that final database with a GUID and restore peace and order to society.

  1. In SQL Management Studio find the database with the GUID, right click on the name, and click Delete. (If you are the nervous type backing it up first isn't the worst idea you have had today.)
  2. Check the box at the bottom for Close existing connections and click OK.

Finally! No more GUID's.

No comments: