Thursday, February 26, 2009

How to change the default database storage location in SQL?

"How do I set the default database file path"I keep seeing this question in many forums. When you fire "CREATE DATABASE " T-SQL command without any parameters. The database will get created and its file will be located in some path, lets say "C:\Program Files\MS SQL\Data". But if you want to have the files located else where, lets assume "D:\SQL_Data\" then there are two options that you can think of.
1 - specify the file path in the "CREATE DATABASE " command or
2- set the default path location in server configuration.
For option one refere to BOL, here is how to workout Option-II: again there are two ways to do this task.
one, using GUI (Management Studio/Enterprise manager) - right click on server node, select properties from pop-up menu, look for "Database Settings" in that section there two boxes - one for LOG and other for DATA file. Key in the appropriate values and save it. This change will effect after stop & start SQL server.
The other way to achieve this configuration change is using T-SQL, as show below,
USE [master]
GO
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultData', REG_SZ, N'D:\SQL_Data'
GO
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultLog', REG_SZ, N'D:\SQL_Data'
GO
Yes, its instance specific registery entry that it takes to set this property. Here the command is using extended stored procedure "xp_instance_regwrite" to do the trick. This type of command can be used in cases where you want to standardise you SQL Server setup and you may want to add this step as a post installation procedure/batch file etc.

Wednesday, February 25, 2009

Failed to register SharePoint Services

When we run Windows SharePoint Products and Technologies Configuration Wizardduring installation, it failed and displayed error "Failed to registerSharePoint Services.An exception of the System.Runtime.InteropServices.COMException was thrown.Additional exception information: Could not access the Search serviceconfiguration database.
The cause and solution:
I looked at the log file, found that the process stopped at STEP 5Calling SPServiceInstance.Provision for instanceMicrosoft.SharePoint.Search.Administration.SPSearc hServiceInstance, serviceMicrosoft.SharePoint.Search.Administration.SPSearc hServiceI did this following steps and the configuration finished successfully.
1. On the Start menu, click Run. In the Open box, type regedit and thenclick OK.
2. In the Registry Editor, navigate to the following subkey, and then deleteit:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web ServerExtensions\12.0\WSS\Services\Microsoft.SharePoint. Search.Administration.SPSearchService
3. Run the SharePoint Products and Technologies Configuration Wizard again.

Tuesday, February 24, 2009

Backup / Restoring SharePoint 2007 Site from SQL Database

I got this excellent article on SharePointdogs for backup / restoring the SharePoint site from SQL DB :
http://sharepointdogs.wordpress.com/2008/07/30/content-migration-or-backuprestore-in-moss-2007/#comment-9
Here is one of defined approach which worked wonders for me :
USING SQL
Using SQL, Backup the SQL Content Databases which are required and Restore them to a new databases in the SQL and attach these databases to the new application.
(Briefly we can say that take your content db ‘Offline’ using the Central admin. Take the content database offline in SQL Studio (Take Offline context menu item). Copy your database mdf and ldf files to the new machine (the destination machine). Attach the copies on the new SQL server using SQL Studio. Add the copied content DB to the Web Application on the new machine using the Central Admin on the new web server.)
STEPS:
1)Find the content DatabaseThese are listed under Central Admin->Application Management->Site Collection List
2) Backup the content databaseYou could alternatively detach it, and copy it. Just doing a backup in SQL Server 2005 Management studio is easier.
3) Restore content database to new serverCopy the BAK file to new server. Create an empty DB in Management Studio, restore from backup, you may need to change an option in the “options” tabof the restore dialog to get it to work. (Overwrite db).
4) Create Web App on new ServerCentral Admin->Application Management->Create or extend Web App->Create New Web App.
5) Associate restored DB with new Web AppCentral Admin->Application Management->SharePoint Web Application Management->Content Databases->Remove Content Database from your new web app.
Now use STSADM to add restored DB to this web appc:\program files\common files\microsoft shared\web server extentions\12\bin on new server is where you can find the STSADM.run this command from there.
stsadm -o addcontentdb -url http://yourwebapp:port -databasename yourcontentdb -databaseserver yoursqlserver
6) Run ISSRESET from command prompt

Delete a SSP (Shared Service Provider) in a farm

You can only delete a SSP (Shared Service Provider) when you have installed SharePoint as a Farm. There are two ways to delete a SSP:
1) Via a browser: http:///_admin/deletessp.aspx?ssiId=
2) Via Command line: stsadm –o deletessp –title

Also keep in mind when you use number 2 it will not remove the two databases created for the SSP and SSP Search. This means you have to go into SQL Server to remove them your self.