Skip to main content

SSRS: Dynamic Data Sources

I have been building dashboard using Reporting Services (SSRS) for a client of mine. The dashboard is going to be used to display useful information on their SQL Server instance, the information contained in the reports will be retrieved from DMVs. Information like the SQL Server wait types, information on a SQL Server instance, along with other useful information such as page life expectancy (PLE) buffer cache hit ratio, Expensive IO queries and the like.  This can be useful when performance tuning and monitoring SQL Server. How I went about creating this report will follow in future posts but in order to get this information ‘real time’ from several different SQL Servers required me to build a dynamic data source.

In this post we will look at how we build this dynamic connection.

First up we need to create a database to hold information on the servers we want to connect to. There is likely to be a nice easy way of getting this information for you automatically using something like PowerShell but for the purposes of this post we will collect the data manually.

Create a database and a table to hold the SQL Server information:

/*create a database to house the server and instance information
--this can be any data source you like
--in my case it's SQL Server database*/
USE [master]
GO

CREATE DATABASE [ServerList]
go

/*Create a simple table to store the SQL Server information*/


USE [ServerList]
GO

CREATE TABLE [dbo].[ServerList](
[Severname] [varchar](50) NULL
) ON [PRIMARY]


/*Populate the table with some server names*/

INSERT INTO [ServerList].[dbo].[ServerList]
([Severname])
VALUES
('
GRE-HP'),
('
GRESERVER')
GO



Create new Report Server Project


We have our list of servers that we want to connect too stored nicely in a database table, next we will create a Report Server Project and  create new report. Our report will show wait times for each server instance, the query for the report is courtesy of Glenn Berry’s (Blog | @GlennAlanBerry) Diagnostic queries. So we’ll create a new project


image


Once we have a new project we need create a new report, right click the reports folder in the “Solution Explorer” and select <New Report> this starts up the Report Wizard:


 


image


Create  a data source to an instance of your choice, we will change this later to connect to a server from a drop-down list.


image


Click next and plug in Glenn’s waits query:


 


image


Complete the report wizard and we should have report that connects to our server and displays information on what SQL Server is waiting on.


Create a Data Set for the server list


Next we need to create a data set that connects to our list of servers


image


We have a data set based on our server list data source. Next up we want to plug this dataset  into a parameter


Create a Parameter


Right-Click on the <Parameters> folder and select <Add Parameter> call it ServerName


image


Select <Available Values> and select <Get Values from a query>


image


The final thing for us to do is pass our parameter into our waits data source so we connect to the correct server as selected by the report viewer. To do this we need to change our waits data source to pass the parameter in as the server name. The code looks similar to this:

="Data Source=" & Parameters!ServerName.Value



We plug this code into the expression on the waits data source


image


 


When we preview our report, we will need to first select a server from our drop down list, and select <View Report> we will then get the waits information from the sever chosen.

Comments

Popular posts from this blog

Always Encrypted

By David Postlethwaite

Always Encrypted is new features in SQL Server 2016 and it is also available in Azure SQL Database. Here you can encrypt columns in a table with a master key and a certificate so that they will appear as encrypted strings to those who don’t have the required certificate installed on their pc.
Once the certificate is installed on the computer then the unencrypted data can then be seen as normal.

The data passes from database to your application as the encrypted value, only the application with the correct certificate can unencrypt the data so it is secure across the wire. This will go some way to resolving the concern of people worried about putting their sensitive data on a shared server in the cloud such as Microsoft Azure and accessing the data across the Internet.

At the time of writing Always Encrypted is only supported with ADO.NET 4.6, JDBC 6.0 and ODBC 13.1 but expect other driver to become available.

The calling application (including SSMS) must also hav…

SQL Server 2012 and Virtual Service Accounts

This post is written by David Postlethwaite
If you are using SQL Server 2012 you will probably have noticed that the default account for the SQL services has changed from that used in previous versions. With SQL 2005 and 2008 the default account for SQL service and SQL Agent service was “NT Authority\System”. This is one the built in accounts on a Windows machine, managed by the machine and selectable from a dedicated dropdown list

The Network Service account was introduced in Windows 2003 as an alternative to using the LocalSystem account, which has full local system privileges on the local machine, a major security concern.
The Network Service has limited local privileges easing these security concerns but when many services on a machine use the Network Service account it becomes harder to track which service is actually accessing resources and performing actions, because all the services are using the one Network Service account.
Also, this account, by default, has sysadmin per…

SQL Server Express v SQL Server Developer Edition

SQL Server Express v  SQL Server Developer Edition
Over the weekend I received the following in an email from Ali Ahmad who asked me some questions about learning SQL Server. We exchanged a couple of emails so I have boiled this down to the most salient points.

Question:
Goal: I want to learn SQL Server inside out… for career progression as DBA/BI/data mining. I'm a data analyst and want to learn inside out about data warehousing.
•I understand relational database concepts...
•I have SQL Server 2014 express installed…
•I need to download the adventure works sample in order to play with it.
•So much knowledge on Microsoft website it's easy to get lost… where do I begin?

SQL Server Express v SQL Server Developer
This is interesting. If you want to learn SQL Server inside out including the Business Intelligence suite of applications I would suggest downloading the developer edition of SQL Server which since 2016 has been made available free of charge. Prior to that there was a f…