Forum Discussion

Vu Manh Tai's avatar
Vu Manh Tai
Copper Contributor
Sep 14, 2018
Solved

Add Content DB in Site

Hi ALL
I add a content DB in my site but i see Current Number of Site Collections = 0 

How do i fix it

 

  • A few things to consider :

     

    1. How did you reattach the content database? Did you run "stsadm -o addcontentdb -url http//[URL] -databasename WSS_content"? Try that , if not already done.

    2. Is the version of the content database you mounted and farm content database the same? If not, please upgrade both servers to the same built number.

    3. If nothing of the above works , then try below :

    $app = get-spwebapplication –identity “url of the problem web app”
    $app.contentdatabases.count

    Run SQL query 

    $db = get-spwebapplication –identity “url of the webapplication that had the null entry” 
    $db.contentdatabses.delete(“guidOfProblemDb”)

    If you get null reference exception, then run the following command.

    $db = Get-SPDatabase -Identity "guidOfProblemDb"
    $db.Delete()

     

    Update site map table in Config DB :

    $db = get-spcontentdatabase -Identity [insert guid of cdb here]
    $db.RefreshSitesInConfigurationDatabase()

6 Replies

  • Vimmi Rawat's avatar
    Vimmi Rawat
    Brass Contributor

    A few things to consider :

     

    1. How did you reattach the content database? Did you run "stsadm -o addcontentdb -url http//[URL] -databasename WSS_content"? Try that , if not already done.

    2. Is the version of the content database you mounted and farm content database the same? If not, please upgrade both servers to the same built number.

    3. If nothing of the above works , then try below :

    $app = get-spwebapplication –identity “url of the problem web app”
    $app.contentdatabases.count

    Run SQL query 

    $db = get-spwebapplication –identity “url of the webapplication that had the null entry” 
    $db.contentdatabses.delete(“guidOfProblemDb”)

    If you get null reference exception, then run the following command.

    $db = Get-SPDatabase -Identity "guidOfProblemDb"
    $db.Delete()

     

    Update site map table in Config DB :

    $db = get-spcontentdatabase -Identity [insert guid of cdb here]
    $db.RefreshSitesInConfigurationDatabase()

    • Vu Manh Tai's avatar
      Vu Manh Tai
      Copper Contributor
      Hi Juan
      i follow step on the link:
      https://docs.microsoft.com/en-us/sharepoint/administration/attach-or-detach-content-databases
      • If you follow the procedure documented there, then you should be good with the attaching process...how many site collections do you have in the original SharePoint Farm where you detached the Content DB?

Resources