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.

How to create an Editable Sharepoint Datasheet View with Content Approval Turned on

Have you tried creating a Datasheet view in Sharepoint then suddenly found out that you can’t edit it even it says “View data in an editable spreadsheet format that is convenient for bulk editing and quick customization”?

Well don’t worry you are not crazy it really works like that when Content Approval turned on in the list.

While a lot of sites out there suggest that you to turn it off and states that “The Datasheet View control does not support making edits to lists that have Content Approval turned on” well that’s not quite correct.  This is even listed on Microsoft Support at http://support.microsoft.com/kb/2274841

Though the solution given by those sites work, it will turn of the functionality that you placed in the first place “the Content Approval”.

Now what I will show you is a solution that will work even with Content Approval turned on as the current solutions out there is not good enough specially when you really have a reason to turn on the Content Approval and want a bulk editing mode, I am not sure though whether this is the best practice but it works.  You don’t need programming in this solution and its simple.  Lets start.

What you need is the Sharepoint Designer, you can download it here http://sharepoint.microsoft.com/en-us/product/related-technologies/pages/sharepoint-designer.aspx.  Once downloaded open the site where the list you want to create a view on is located.

Once in the site structure, go to All Files -> List -> Your List (in our example it is called “Some List”) -> then you will see an aspx file called mod-view.aspx.  Copy, Paste and Rename it to what you want.  That file is used as a template for Approve/reject items if you are wondering.

I will call mine “Editable Grid View Working” that’s all you need in Sharepoint designer.  Now go to your list’s default view.  Go to your copied aspx file manually by your web browsers URL. i.e http://yoursharepoint.com/yoursite/List/yourlist/yourcopiedfile.aspx) <- Change the red ones

Once there choose Modify View

Rename the view, it will have the Name property of the Old one, in this example we named it as “Editable Grid View Working” similar to its aspx filename.  Then choose any setting that you want.

Click OK then you can see the new view now

Go to the Datasheet View and Presto! You can now edit in the grid view with Content Approval on.

Now you might be wondering why don’t we just create it from Web UI using the “Start from an existing view” method.  Well that would not work as I had tried that option as well.

Notes:

1. You need to give the user permission to approve and reject items so that they can edit it.
2. I only tried this on Sharepoint 2010 Foundation

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

Follow

Get every new post delivered to your Inbox.

Join 773 other followers