Problem: How to remove Orphan entries from the Sharepoint database?
Solution: 1.Log on to the Central Admin server with the farm admin account 2.Log on to the Central Admin portal using farm admin account. 3.Go to Application Management> Content databases 4.Change the web application of which you want to detach the content database. 5.Click on the database name and at the bottom of the page you will find check box to remove the content db. Click on it and click remove, ignore the warning message. Do not worry it will not delete the database from the SQL database server. Just that it will remove the reference to the web application.
6.Now next step is to attach the database. 7.Open the command prompt and browse to 12 folder. 8.Type the following stsadm command; 9.stsadm –o addcontentdb –url http://WEBAPPURL -databasename yourdatabasename
This will remove the orphan entries from the database.