Thursday, 22 November 2012

Renaming SharePoint Database Names

Renaming crazy SharePoint Database Names

When SharePoint 2007 creates new Content Databases, by default it adds a GUID to the end of the database name.  While you can rename it during the creation process, maybe you forgot to and you now you have a Content Database that looks like the one below (which I intended to hold my “My Sites”).  Fortunately, my friend Priyo showed me how to rename the databases.
To rename it, we are going to:
  • Take the database Offline (so nobody adds anything to it while we are renaming)
  • Detach the database from SharePoint
  • Back up the database using SQL Management Studio
  • Restore the database using our desired name using SQL Management Studio
  • Re-attach the database to SharePoint
Start by going to Central Administration –> Application Management and click on Content Databases
Select the Web Application associated with the database you want to rename, and click on the Database name itself.
Change the Database Status to Offline (which just makes it so that no new sites can be added to the database), click OK.  Click on the database again, select “Remove content database” and click OK.  This does not delete the database, just removes it from SharePoint.
Switch over to SQL Management Studio, and back up the database, then take it offline.
Next… restore the database
And choose a friendly name to restore the database to.  In this case, it will be the ContentDB for my My Sites.
Switch back over to Central Admin (you probably still have open) and click on “Add a content database”
Change the database to your new friendly name, and hit OK.  Voila!  You now have a database name that makes sense.  Once you have verified that everything still works, you can go back into the SQL Management Studio and delete the database that you previously took offline.
Note: There are some special considerations when talking about the SharePoint AdminContent database, as the GUI does not give you an opportunity to name it during initial setup, and following the GUI method will lock you out of the GUI as soon as you remove the database.  The three following posts will walk you through that process, and I’ll try to do the same with screenshots in the next few days.

The file exists. (Exception from HRESULT: 0x80070050) ERROR

The file exists. (Exception from HRESULT: 0x80070050) ERROR

Recently a guy from our 3rd line team thought it would be funny to delete my account from AD. This has now been re-added. Everything is back to normal apart from my Access to Sharepoint sites. I am getting The file exists. (Exception from HRESULT: 0x80070050)Error on all sites.
After some googleing I came across a guy with the same issue and it was an issue with the SID being different from my old account. Since this I deleted my account from Site Administrators and re-added. This would refresh the SID with the new one. I also check on the Content database that the site ID matched using the following transactions and the SIDs match.

select s.Id, w.FullUrl from Sites s inner join Webs w on 
s.RootWebId = w.Id 
select * from UserInfo where tp_Login='domain\username' and 
tp_SiteID='<ID Code>' 
I am now a bit clueless


delete user using spadm command or directly from SP: Actions -> web site settings-> users and permissions -> advance permissions
and delete user info from UserInfo table in SP content db.
delete from UserInfo where tp_Login= 'domain\login'
create account again using standard SP actions or just login to portal using this account.

Set a Database to Single-user Mode Using SQL Server Management Studio

Set a Database to Single-user Mode Using SQL Server Management Studio

To set a database to single-user mode
  1. In Object Explorer, connect to an instance of the SQL Server Database Engine, and then expand that instance.
  2. Right-click the database to change, and then click Properties.
  3. In the Database Properties dialog box, click the Options page.
  4. From the Restrict Access option, select Single.
  5. If other users are connected to the database, an Open Connections message will appear. To change the property and close all other connections, clickYes.

Friday, 2 November 2012

Moving the SQL Server Database to another Drive

Please follow these simple steps to move database from c drive to another drive on Microsoft SQL server 2008 using detach and attach methodfrom Microsoft SQL Management Studio GUI

1- Open Microsoft SQL Management Studio with administrative account.

2- R/Click on the DataBase you want to move and select Tasks Detach.

3- In the Detach screen check drop connections check box to drop any active connections before detach the database.

4- click ok to begin detach the database.

5- after successful database detach navigate to database file  location "database.mdf" and database log "database.ldf".

6-  Copy files to the destination directory that you want to move database to it.

7- Set NTFS permissions for the Moved database and log files as the source database.

8- From SQL Management Studio R/Click database and select attach database

9- From the attach window select database files from the new location "database.mdf" and logfile "database.ldf"

10- Click Ok and the database is now attached from the new location.

11- Delete the old database files if you don't need them.