Wednesday, January 27, 2016

Restore a Site Collection using PowerShell

Restoring the site collection once it gets deleted inadvertently.

You need the full URL of the site collection which you want to restore back to start. 
 
Step1 : For Example, I have a root level site collection having full URL as "http://<<host name>>:10000".
You  can execute Get-SPSite cmdlet to get the site object.
 $mysite = Get-SPSite http://<<host name>>:10000
 
Step2: You can print the GUID of that site by using "id" property of that object in last step.
PS C:\Users> $mysite.id
Guid
----
7044efc1-786f-493b-b3d5-0056add40bb9
 
Step 3: Then you can use "Get-SpDeletedSite" cmdlet with the id as a parameter to confirm the other details of that site collection such as path and deletion time.
 
PS C:\Users\> Get-SPDeletedSite $mysite.id
WebApplicationId   : 740953c9-7041-4130-994a-7d85864975d3
DatabaseId         : 78e0f455-c59d-4404-83c7-085309762fdc
SiteSubscriptionId : 00000000-0000-0000-0000-000000000000
SiteId             : 7044efc1-786f-493b-b3d5-0056add40bb9
Path               : /
DeletionTime       : 1/26/2016 9:40:22 PM
 
Step 4: Last step is to run "Restore-SPDeletedSite" cmdlet with the "-Identity" parameter. You have to pass on the same id or GUID which you got in last steps. Press 'Y' for confirmation.
 
PS C:\Users> Restore-SPDeletedSite -Identity $mysite.id
Confirm
Are you sure you want to perform this action?
Performing operation "Restore-SPDeletedSite" on Target "/".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help
(default is "Y"):Y
 
After execution of step4, your site collection would get restored back.
 

Thursday, January 7, 2016

Run a SQL Server procedure from Excel


I'm using SQL Server 2008 Enterprise. I created a stored procedure in one database. The stored procedure is composed of several queries from the same database. Final combined result set is being displayed.

I try to execute it via Excel to create a report from the output which I got from stored procedure, so the results will appear automatically in Excel sheet, but I'm getting the below error:


Once I was creating the SP with the simple SQL Queries, it was working fine, but not for the stored procedure which are having multiple queries, loops and other functionality

After trying various different option, I found the solution of this.

I added "SET NOCOUNT ON" to the beginning of the stored procedure.

Here is the link which can be helpful to read about this.
https://msdn.microsoft.com/en-us/library/ms189837.aspx