SSRS 2016: You are not allowed to view this folder. Contact your administrator to obtain the necessary permissions.

In this article, I will solve the below issue in SQL Server Reporting Service 2016

Could not load folder contents
You are not allowed to view this folder. Contact your administrator to obtain the necessary permissions.

Reporting Service 2016 - You are not allowed to view this folder. Contact your administrator to obtain the necessary permissions.
Applies To

SQL Server Reporting Service 2016.


Steps

Continue reading “SSRS 2016: You are not allowed to view this folder. Contact your administrator to obtain the necessary permissions.”

Advertisements

SQL Server: Get the Detailed Information Via SERVERPROPERTY

In this article, we will explain

  • How to get the SQL Server Instance Information using “SERVERPROPERTY”?
  • How to get the SQL Server Instance Information remotely?

What’s the SERVERPROPERTY?

SERVERPROPERTY is a System Defined function used to return the SQL Server Instance Information.

SERVERPROPERTY Syntax

SERVERPROPERTY ('propertyname')

propertyname is one of the following values.

  • MachineName.
  • ComputerNamePhysicalNetBIOS.
  • ServerName.
  • InstanceName.
  • InstanceDefaultDataPath.
  • InstanceDefaultLogPath.
  • Edition.
  • EditionID.
  • EngineEdition.
  • ProductBuild.
  • ProductBuildType.
  • ProductLevel.
  • ProductMajorVersion.
  • ProductMinorVersion.
  • ProductUpdateLevel.
  • ProductVersion.
  • BuildClrVersion.
  • Collation.
  • LCID.
  • IsSingleUser.
  • IsIntegratedSecurityOnly.
  • IsHadrEnabled.
  • HadrManagerStatus.
  • IsAdvancedAnalyticsInstalled.
  • IsClustered.
  • IsFullTextInstalled.
  • ProcessID.

Continue reading “SQL Server: Get the Detailed Information Via SERVERPROPERTY”

SQL Server: How to get the current installed update level

Consider you need to install a new Cumulative Update or Service Pack on your current SQL Server, but you don’t know what’s the current update level that already installed in your environment!!

In this article, we will explain

How to detect the current Cumulative Update / Service Pack that was installed on SQL Server.


Detect the Current Cumulative Update / Service Pack Installed

You can use the ServerProperty as a system defined function to return the SQL Server Instance information like the ProductLevel and ProductUpdateLevel

The ProductLevel returns the version level of the SQL Server instance as the following.

  • RTM‘ = Original release version
  • SPn‘ = Service pack version
  • CTPn‘, = Community Technology Preview version

Example 


select SERVERPROPERTY('ProductLevel') as 'Product Level'

Detect the Current Cumulative Update / Service Pack

Continue reading “SQL Server: How to get the current installed update level”

Convert Rows To Columns Using Dynamic Pivot In SQL Server

In this article, I will explain

How to convert rows to columns using Dynamic Pivot in SQL Server?

Download The code sample for this demo from TechNet Gallery: Dynamic Database Structure – Convert Rows to Columns Using Dynamic Pivot


Scenario

We have decided to build a dynamic database by creating only three tables as shown below:

convert rows to columns using Dynamic Pivot in SQL Server

  • The “Tables” will be used to hold the table names like Users, Products….etc.

Tables - convert rows to columns using Dynamic Pivot in SQL Server

  • The “Fields” will be used to hold the fields name related to each table.

convert rows to columns using Dynamic Pivot in SQL Server

  • The “Field Value” will be used to hold the value of each field.

Field Values - convert rows to columns using Dynamic Pivot in SQL Server

  • The relationship between the three tables is one-many and the ERD looks like the below:

convert rows to columns using Dynamic Pivot in SQL Server

The desired data should look like:

Dynamic Pivot In SQL Server

PIVOT rotates a table-valued expression by turning the unique values from one column in the expression into multiple columns in the output and performs aggregations where they are required on any remaining column values that are wanted in the final output.


Steps

Get a list of the “Field Values” (Rows)

Get a list of “Field Values” that should be shown as Rows by doing the following:

  • Create a table “data-query” that will hold the field data values.
BEGIN try
 DROP TABLE ##dataquery
END try

BEGIN catch
END catch

CREATE TABLE ##dataquery
 (
 id INT NOT NULL,
 tablename VARCHAR(50) NOT NULL,
 fieldname VARCHAR(50) NOT NULL,
 fieldvalue VARCHAR(50) NOT NULL
 );
  • Query the field values data filtered by “TableID” and insert the output into the created table in the above step.
INSERT INTO ##dataquery
SELECT Row_number()
 OVER (
 partition BY (fields.fieldname)
 ORDER BY fieldvalue.fieldvalue) ID,
 tables.tablename,
 fields.fieldname,
 fieldvalue.fieldvalue
FROM tables
 INNER JOIN fields
 ON tables.tid = fields.tid
 INNER JOIN fieldvalue
 ON fields.fid = fieldvalue.fid
WHERE tables.tid = @TableID

Output

convert rows to columns using Dynamic Pivot in SQL Server

Get a list of the “Fields” (Columns)

Retrieve the list of the fields filtered by “TableID” by using the below SQL statement


DECLARE @DynamicColumns AS VARCHAR(max)

SELECT @DynamicColumns = COALESCE(@DynamicColumns + ', ', '')
 + Quotename(fieldname)
FROM (SELECT DISTINCT fieldname
 FROM fields
 WHERE fields.tid = @TableID) AS FieldList

COALESCE: Evaluates the arguments in order and returns the current value of the first expression that initially does not evaluate to NULL.

Quotename: Returns a Unicode string with the delimiters added to make the input string a valid SQL Server delimited identifier.Build the Dynamic Pivot Table Query

Build the Dynamic Pivot Table Query

In this section, we will combine the above two queries to can build our Dynamic Pivot


DECLARE @FinalTableStruct AS NVARCHAR(max)

SET @FinalTableStruct = 'SELECT ' + @DynamicColumns +
' from ##DataQuery x pivot ( max( FieldValue ) for FieldName in (' + @DynamicColumns + ') ) p '

EXECUTE(@FinalTableStruct)

Output

convert rows to columns using Dynamic Pivot in SQL Server


Convert rows to columns using Dynamic Pivot in SQL Server

Finally, the Dynamic Pivot Script should look like


DECLARE @TableID AS INT

SET @TableID=1 -- Set Table ID

-- Get a list of the "Field Value" (Rows)
BEGIN try
DROP TABLE ##dataquery
END try

BEGIN catch
END catch

CREATE TABLE ##dataquery
(
id INT NOT NULL,
tablename VARCHAR(50) NOT NULL,
fieldname VARCHAR(50) NOT NULL,
fieldvalue VARCHAR(50) NOT NULL
);

INSERT INTO ##dataquery
SELECT Row_number()
OVER (
partition BY (fields.fieldname)
ORDER BY fieldvalue.fieldvalue) ID,
tables.tablename,
fields.fieldname,
fieldvalue.fieldvalue
FROM tables
INNER JOIN fields
ON tables.tid = fields.tid
INNER JOIN fieldvalue
ON fields.fid = fieldvalue.fid
WHERE tables.tid = @TableID

--Get a list of the "Fields" (Columns)
DECLARE @DynamicColumns AS VARCHAR(max)

SELECT @DynamicColumns = COALESCE(@DynamicColumns + ', ', '')
+ Quotename(fieldname)
FROM (SELECT DISTINCT fieldname
FROM fields
WHERE fields.tid = @TableID) AS FieldList

--Build the Dynamic Pivot Table Query
DECLARE @FinalTableStruct AS NVARCHAR(max)

SET @FinalTableStruct = 'SELECT ' + @DynamicColumns
+
' from ##DataQuery x pivot ( max( FieldValue ) for FieldName in ('
+ @DynamicColumns + ') ) p '

EXECUTE(@FinalTableStruct)

Output
How to use Dynamic Pivot in SQL


Applies To
  • SQL Server 2017.
  • SQL Server 2016.
  • SQL Server 2012.
  • SQL Server 2008.

Download

To download the Database Backup and the Dynamic Pivot Script Check TechNet Gallary.

 

SQL Server Versions supported with SharePoint 2016

In this article, I will explain How to

Which versions of SQL Server is supported with SharePoint 2016?

SQL Server Versions supported with SharePoint 2016


First, It’s recommended to check the Hardware and software requirements for SharePoint Server 2016 before you are going to Install SharePoint 2016,

In Hardware and software requirements for SharePoint Server 2016 article, specifically in Database Server requirements section, you will note that the database server requirements is one of the following:

  • The 64-bit edition of Microsoft SQL Server 2014 Service Pack 1 (SP1)
  • Microsoft SQL Server 2016 RTM.

Actually, that made me puzzled to maintain

  • The compatibility of SQL Server 2014 SP2 with SharePoint 2016.
  • The compatibility of SQL Server 2016 SP1 with SharePoint 2016.

So let’s answer the below questions to make it clear!


How to maintain SQL Server and SharePoint Compatibility? Continue reading “SQL Server Versions supported with SharePoint 2016”