Showing posts with label SQL Server. Show all posts
Showing posts with label SQL Server. Show all posts

Friday, February 26, 2016

PowerShell to know the SQL Server DB Name for a site collection

SQL Server DB Name for a specific SharePoint site collection

If you are having the central admin access of SharePoint, then follow the below steps to know the Database name of a particular site collection


Follow these steps:
  1. Open Central Administration.
  2. Go to "Application Management".
  3. Click on "View all site collections".
  4. Select the site collection you need to get the database name.
  5. In the panel on the right you should see "Database Name", that's the name of the content database.


If you are not having central admin access, you can use the PowerShell to know the same.  Open SharePoint 2010 Management Shell.

PS C:\Users\<username> $url="http://<host-name>/sites/<site collection name>"
PS C:\Users\<username> $site = Get-SPSite $url
PS C:\Users\<username> $site.ContentDatabase.name
WSS_Content

So in this case "WSS_Content" is the Content Database Name which is  being used by this site collection.



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