Migrate SharePoint’s SQL Server to another SQL Server (same or new version)

This is a step by step guide on how you migrate your SharePoint’s (I used 2010 version in this instance) SQL Server to an new SQL Server host.  In this exercise I tried migrating it in a new version of SQL server which is 2012 from 2008 R2, also had tried it in the same version.  There are only 9 steps to perform this task but it takes into consideration you already have a new SQL Server provisioned.

Lets start

1. Stop all SharePoint and IIS Related Services

  • SharePoint 2010 Administration
  • SharePoint 2010 Timer
  • SharePoint 2010 Tracing
  • SharePoint 2010 User Code Host
  • SharePoint 2010 VSS Writer
  • SharePoint Foundation Search V4
  • World Wide Web Publishing Service
  • SharePoint Server Search 14
  • Web Analytics Data Processing Service
  • Web Analytics Web Service

1 Stop Services

2. Stop IIS
At the command prompt under admin context, type iisreset /stop

3. Detach all related SQL Server databases

  • Configuration database
  • Central Administration content database
  • Content databases
  • Service application databases

i.e.
Bdc_Service_DB_xxxxxxxxxxxxxx
SharePoint_AdminContent_xxxxxxxxxxxxx
SharePoint_Config
WSS_Content
WSS_Logging
WSS_Search_xxxxxxxxxxxxxx

2 Detach Database

4. Move all database files (.mdf, .ldf, and .ndf) to the new server.

Place it in the data folder of the SQL Server instance of the new host.

3-copy-database-files

5. Set up same user permissions on the new SQL server

best way to do this is when you use AD accounts is by scripting the users on the old server and running that script on the new server. If you are not using AD accounts then you will have issues with passwords so best way to do that is to follow this -> http://support.microsoft.com/kb/918992

6. Attach your databases to the new SQL Server

4 Attach Database

5 Attach Database 2

7. Verify what ports your New SQL is using

If it’s using a dynamic port change it to static. To do this go to SQL Server Configuration Manager and into the SQL Server Network Configuration Section choose the instance you will be using. Go to the TCP/IP section and if TCP Dynamic Ports are set to 0 (zero) then remove that and assign a static port into the TCP Port Section on all IP’s. For this sample we will be using 14330 <- notice I just added 0 at the end from the default port. Note that as we will need that on the next section also if you changed the port number from dynamic to static you will need to restart your SQL Server before it can take effect.

6 Port Allocation

8. Go to your SharePoint server and create your SQL Server Alias

If SQL Configuration Manager is installed just head over to the SQL Native Client 10.0 configuration then into Aliases. Create a new alias that points to your new SQL Server by right clicking on the Alias. You need to do this on both 32 and 64 bit instances.

7 Alias Configuration

  • On the Alias name put your old SQL Server IP or Name
  • On the Port the port you indicated on step 7, in this case 14330
  • Protocol should be TCP/IP
  • And on Server the new SQL Server IP or Name together with its instance name if there is any. In our case it’s SQL2012

7 Alias Configuration 2

If you don’t have SQL Configuration Manager in your SharePoint Server then run the CLICONFIG again on both 32 and 64 bit instances. For 32 bit go to run command and execute this “%SystemRoot%/SysWow64/CliConfg.exe” and for 64 just this “CLICONFG” all without quotes of course. Add the same info as above.

7 Alias Configuration b

9. Start all your SharePoint services, now you have successfully migrated your database.  

  • SharePoint 2010 Administration
  • SharePoint 2010 Timer
  • SharePoint 2010 Tracing
  • SharePoint 2010 User Code Host
  • SharePoint 2010 VSS Writer
  • SharePoint Foundation Search V4
  • World Wide Web Publishing Service
  • SharePoint Server Search 14
  • Web Analytics Data Processing Service
  • Web Analytics Web Service

At the command prompt under admin context, type iisreset /start.

Moving a Sharepoint Sub Site to its own Site Collection in 3 easy steps

Moving a Sharepoint Sub Site to its own Site Collection why should I do that?  Well there might be a lot of reasons on doing this but for me its more handing over the Site collection Administration to the business which enables business owners to choose themes, manage security within the site collection, manage activated solutions and deploy other customizations.  Another good reason for me is about Quota Management which I can’t do in a Sub Site model.  How about you whats you reason?

So whatever your reason is I guess you either want to do it or thought of doing it that is why you are reading this article.  So let’s get started and perform that 3 easy steps in moving your Sub Site in its own Site Collection.

On this demo we will be moving a Sub Site called “Sandbox” which is located in http://someURL/SomeTeamSite/sandbox


Step 1: Export your subsite by using the Export-SPWeb command.

You can do this on your Sharepoint Server and run the command using the SharePoint 2010 Management Shell.  For this sample I had used the following command

Export-SPWeb -Identity "http://someURL/SomeTeamSite/sandbox/" -Path "C:\Exported Sub Site\SandboxSubsSite.cmp" -IncludeUserSecurity -IncludeVersions all

What that command does is basically export the sub site to a .cmp file where we included all Security Settings and Versions for more options check out Export-SPWeb on TechNet

You will notice once it exports you will have a log file showing you whats been done during the export process.

Step 2: Create you site collection.  This is where you will host your new site.  

Still on the Sharepoint Server (you can also do this remotely), go to “SharePoint 2010 Central Administration” then into “Application Management” then “Site Collections” then “Create a Site Collection”.

Indicate all of the properties needed

Take note you can also create managed paths, which means you can create a site at a specific path. To do that click on “Define Manage Paths” under the “Web Site Address”.

Once everything is set up properly you will receive a confirmation that your site collection was created.

Step 3: Import your Content Migration Package (CMP) file that you exported using Import-SPWeb.

Still in the Sharepoint Server using the SharePoint 2010 Management Shell issue the Import-SPWeb command, for this sample it would be something like this

Import-SPWeb "http://someURL/sites/Sandbox" –Path "C:\Exported Sub Site\SandboxSubsSite.cmp"

Like Export-SPWeb the Import-SPWeb can have several parameters which you can see on TechNet

It will also create an Import log and once the import finishes your all good to go.

Now check your new site collection and compare to the sub site, and if your happy feel free to remove the subsite.

Sharepoint List View Threshold Error

You might have encountered the error below in Sharepoint thats why you stumbled upon this site.

The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator.<nativehr>0×80070024</nativehr><nativestack></nativestack>

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator.0×80070024</nativehr><nativestack></nativestack>

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Before I give you the solution, lets see why does it happen on the first place so you can better understand what you are fixing.  The error basically about the size of the database operation that you are executing in one go, which means it can be viewing a list, loading a page or other database related operations.  That error simply says that the number of operations that exceed the limit set on the server this is now treated as an Expensive Query Exception.  Now you might notice that your user’s experience this error but not yourself this is because if you are an Administrator then you have higher thresholds.

Now how do you adjust this thresholds.  All you have to do is go to Central Administration -> Application Management -> Manage Web Applications then highlight the Name of the site you are adjusting the threshold

Then choose General Settings on the ribbon, then Resource Throttling.

Now you can change your setting on the List View Threshold, by default it is 5000 so you can increase it to something like 10000 to double the operation count.  Now you can also see the setting List View Threshold for Auditors and Administrators, that’s the reason why you don’t see the error as it is defaulted to 20000, but if you are an administrator and you have the same issue you can increase both settings.

This should fix your issue now, so go back what you were doing before it happened and it will not throw any exceptions anymore.

Using jQuery with Sharepoint 2010

Several days back I was asked a question in this blog relating to using JavaScript in a Sharepoint, it ended up with multiple questions and one was using jQuery in Sharepoint, as usual I searched my own blog for answers becuase that is one of my main reasons having this is to store information like this that I may need in the future, a reference for what I had done which I may be able to use again someday.  Anyways as I was searching and I found out that I havent posted this article, I thought I already have made one before but no, so this will be my chance.

So how would you use jQuery in Sharepoint? You can follow this easy steps and you will be ready to go in minutes

1. Download jQuery

Download latest verion of jQuery here  http://docs.jquery.com/Downloading_jQuery

2. Save it in an accessible location in Sharepoint

Using Sharepoint Designer I added a Folder called “Scripts” inside the “Style Library” of the root level of the site. I then added the latest jQuery File into that folder.

3. Place a reference on that jQuery from your code

The best place for this will be your master page so that it can be used anywhere in your site, so open the master page (by default SharePoint 2010 uses v4.master) you are using in Advanced mode then add your javascript reference like such.

<script src="/Style%20Library/Scripts/jquery-1.6.2.js" type="text/javascript"></script>

you place that inside the <head> tag

Save that master page and you are ready to go

4. Test if its working

If you are using FireFox open up firebug or if you are using IE you can press F12.  Go to the script tab to check whether your javascript reference is there, then on the console window try wether that reference works by typing something like this.

$("#MSO_ContentTable").text("Welcome to Sharepoint jQuery")

you should get a result something like this

Easily Determining what is the exact Error by using Correlation ID in Sharepoint 2010

Have you encountered an error that looks like this screenshot below?

Well if you develop items in Sharepoint then most probably you had seen that not just once but a lot of times unless you are a really good developer that does not commit any mistakes.

Now you are presented with a GUID without any other information so you might be wondering what the hell that means, so you Googled your problem and saw some solutions on how to determine what does that Correlation ID means by going to the server and in this folder location

    C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS

and whoalla! you see a ton of logs that Sharepoint had generated over time.

You then opened the log specific to time when your issue happened and to your surprise that GUID is non existent.  To your dismay you searched other logs that are near to the time your issue happened but still there’s not luck.  Well there are other easier means in searching for what you want and that is through the Microsoft SharePoint 2010 Administration Toolkit v2.0.

That toolkit have some of the tools you need for diagnosing issues like such plus more, it has Load Testing Toolkit, User Profile Replication, Content Management Interoperability Services and much more.  Viewing logs is never
been easier as the results are presented in a much meaningful way.  So how do I use the tool to check what that correlation ID means? Well here are the steps:

1. Install the tool in your server or even in your local machine that can connect to that server, installation file can be downloaded here for free.  Once downloaded installation is straightforward.

2. Once installed, its time to create your project.  First find the application on your start menu then go to SharePoint 2010 Administration Toolkit -> SharePoint Diagnostic Studio.  Open that then click new project, you will then be presented with a screen similar to below, put your server name on the text box then hit “Create Project”.  Be patient it will take sometime to process that.

3. Once finished you will be presented with this screen, with some information.  In other slower servers you might see it a bit later and it will show “building report please wait…” but don’t worry its processing at  the background also please take now if there’s no data it retains that message.

4. Now you can start searching for your issue by clicking the search button on top.

5. Populate the needed text boxes and hit OK

6. Now you will be presented with what you are looking for.

Follow

Get every new post delivered to your Inbox.

Join 773 other followers