You restore a content db via SQL restore and attach it to another SharePoint web application via Central Administration "Add a content database" and for some reasone the "Current Number of Sites" is 0. WTF? You are sure the content db has content.
In the Application Event Viewer you find the following error...
Event Type: Error
Event Source: Windows SharePoint Services 3
Event Category: Database
Event ID: 5763
Date: 5/18/2007
Time: 9:42:26 AM
User: N/A
Computer: TEAS-207
Description:
Primary key violation on SQL Server instance 'teas-207' in database 'SharePoint_Config'. Additional error information from SQL Server is included below.
Violation of PRIMARY KEY constraint 'PK_SiteMap'. Cannot insert duplicate key in object 'SiteMap'.
The statement has been terminated.
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Here is the workaround. First find out the Id of the sites (site collection) in the [restored_db].Sites then delete the line in the [Config_db].SiteMap with the same Id. Now attach the content_db and you should see the sites.