I am sure you have seen enough blog posts on this and so I thought will add one more to the ever growing list!!
So for last few days I have been working with one my my colleagues to install and Configure Enterprise Portal (AX 2009) with SharePoint 2007 Farm (1 WFE + 1 App Server connecting to SQL) – it’s a different war altogether but let me tell you how we landed up with multiple orphan site collections. EP was failing to install every time (and we did this at least 10 times) since it could not create the site collation with the Custom Site Definition. we finally got around it, but in the process EP installer was invoking a web service to create the namespace every time >> http://<sharepointSiteDNSName>/sites/DynamicsAX .
Finally when the EP installation completed successfully we could not browse the EP Role Center Site. after few hours of banging our head we finally went in SQL (ContentDB >> Site table) and saw a bunch of entries which shouldn’t be there >> Touching SQL Content Db in SharePoint is not supported – so don’t do it, I will tell you how to find orphan sites without touching SQL.
when you run stsadm –o databaserepair command – it shows the orphan items in a content DB .. however, our showed 0, reason being, there wasn’t anything in the content DB per say. so what to do??
Make sure you have SP2 for MOSS first.
There are primarily two ways to find this out.
preupgradecheck – it not for upgrade only. it checks your MOSS health and lets you know what you should be doing. ideally you should run this on a scheduled manner to ensure MOSS is healthy. We ran stsadm –o preupgrade and it did tell us the bunch of orphan site collections
Below this it also notifies to run databaserepair and or detach / attach content DB – we did this but it didn’t resolve the issue and preupgradecheck continued to report the orphaned site collections
enumallwebs – this was the savior !! this command runs against content DB and not on a URL context. We ran it and it displayed some 8 sites where the InSiteMap property was False. this denotes that the Site Collections are orphaned. See below:
The command is stsadm –o enumallwebs –databasename YourSQLName –databaseserver YourSQLServerName
ok so we found the orphan addresses, now clean up time. Since attach / detach and databaserepair with deletecorruption switch didn’t help us, we decided to manually delete the Sites with SiteID. if you note above, EnumAllWebs shows the GUID of the Sites that we will use to delete them and clean up the WebApp
The command to run here is : (copy site ID from above output for all of them where InSiteMap=False) – http://technet.microsoft.com/en-us/library/cc288016(office.12).aspx
stsadm -o deletesite -force -siteid 40ca628e-8d7c-461b-9340-c5bb518cf399
-databasename wss_content_ep -databaseserver sql08W2008X64
That did it!! to Verify, we ran preupgradecheck again and it didn’t report any Orphan Site Collections.
Hope this helps.