Showing posts with label SSRS. Show all posts
Showing posts with label SSRS. Show all posts

Monday, October 17, 2016

Linked Report (Drill through ) Reports in SSRS


A Linked report or Drill through report is a report which will open the another report to get the detail report. In order to show this I have created two reports.

1) StudentExamStatus
2)StudentExamStatusDetail

The report StudentExamStatus show the report of students whether they have passed or failed. The second report StudentExamStatusDetail shows the particular student information with the score they have achieved in each exam.

First Report Query text

create table #studentmarks (studentid int identity(1,1),studentname varchar(50),subjectname varchar(250),marks smallint,Ispassed Char(1))
insert into #studentmarks values ('A','Social',80,'P'),
                                                       ('A','Science',50,'P'),
                                                       ('A','English',90,'P'),
                                                       ('B','Social',30,'F'),
                                                       ('B','Science',50,'P'),
                                                       ('B','English',90,'P'),
                                                       ('C','Social',80,'P'),
                                                       ('C','Science',70,'P'),
                                                       ('C','English',90,'P')
select studentname,
(select top 1 (case  IsPassed when 'P' Then 'Passed'
                           WHEN 'F' then 'Failed' else null end) from #studentmarks s1 where s1.studentname = s.studentname order by Ispassed asc) AS ExamStatus
from #studentmarks s
group by studentname
drop table #studentmarks

Create a Data Source.




Use the Data Source as Shared Data Source so that all the data sets can use the same connection string.



Create a Data Set for the first report as shown below.






StudentExamStatus Report Design



The SSRS 







The Second Report StudentExamStatusDetails DataSet






Saturday, June 6, 2015

Working with Indicators in SSRS

How to use Indicators in SSRS :

Indicators in SSRS are useful to show the report in symbolic representation of the Status/Progress of the Fields in the report. By using the Indicators its easy to understand the report. It gives rich interface to the report.

The below example shows how to use indicators in SSRS reports.

Go To Report in Data Tools




Add New Item. Select Report and Click Ok.


Go to Tool Box and Drag and Drop the table.Add 3 columns. Name,marks, Scrore/Grade. 




Create Data Source and Create Data Set using the Report data .



create table #studentmarks (id int identity ,name varchar(50), marks int );
insert into #studentmarks values ('malli',80),('naga',60),('eswar',30),('reddy',50)
select name , marks from #studentmarks
drop table #studentmarks

The above sample query gives output of studentmarks.

Place the Indicator in the Pass/ Grade  text box as shown below. There are 4 different Indicator types as shown below. 

  • Directional : Showing Directions
  • Symbols : Showing the Pass/Fail Status ,Correct/Incorrect
  • Shapes : Showing different shapes triangle/circle etc
  • Ratings : Showing rating using different icons stars/bar/charts


Select rating tab. Click Ok.



Right Click the Score Grade text box (Star symbol area) as shown below.




Click on Indicator properties as show below. Go to Value and States tab as shown below.

By default there are two measurement units available for indicators

1) Numberic
2)Percentage 

Here in the below example I have used the numeric to show the indicators


Value drop down can be use the sum and count of integer column fields. To change the expression of the value column click of fx. Select Fields (dataset) Category and select marks field.


Click ok. Then save the indicator properties and run the reports. The Out put of Report UI can been seen below.










Thursday, May 21, 2015

Create Subscriptions in SSRS (SQL Server Reporting Services)

How to Create Subscription in SSRS 

The User Interface has been changed Slightly in SQL Server for SSRS report manager.

The old Interface in Report manager to create reports. When Click on report it will show the settings in tabular mode. By default it will show report view mode.



In SQL Server 2012 Microsoft has changed the user interface of report manager for creating subscriptions. This is



Click on Subscribe.  It will Report Delivery options.  



The Different options under Delivery types are 




By default E-mail will be selected. Select E-mail , T0 , CC,Subject. Select the Check Box include report so that report will be send as attachment . There are different rendering formats for sending the report as attachment.



These settings can be done in RSReporServer config file. The RSreport server generally stored in the similar path given below.






C:\Program Files\Microsoft SQL Server\ReportServerName\Reporting Services\ReportServer\RsReportServer.config

Click on schedule to schedule the report to run a specific time.



Select Schedule of report (daily,weekly etc). Select the start date of the report that need to schedule.

The prerequisites for creating SSRS Subscriptions are

1) Create SQL Login and  map the login ReportServer Database. ReportServer Database will be created when SSRS services installed.  



2) In Report Manager Go to Data source. Click on Data Source as shown below.


3) Select the option Credential stored securely in the report server and provide SQL username and password. Click on Test connection to test the connectivity and Click on Apply.











Monday, May 11, 2015

Deploy multiple in SSRS using PowerShell


Using Power shell we can Deploy multiple Reports in folder to SSRS Report server. It is easy to deploy all the reports at a time using the power shell script.


The script can be download using the following link.


Deploy Multiple Reports using a common datasource.


It requires four mandatory parameters.

1) Reporturl :  The Report Server URL. The Report manager is used for publishing /Viewing the reports. 


2) ReportFileFolderPath :  The local path that report exist in the folder.


3)ReportServerFolder :  Report Server folder path for deploying reports. Report server maintains the folder hierarchy to maintain the report level permissions.


4) Reportserverversion : The report webservice version. For SQL Server 2005/2008 it uses the report webservice 2005, For SQLserver 2008 R2/2012/2014 it uses the Report webservice 2010.


The important methods and commands that are used in the script.

Get-Childitem : List all the files in a folder. In this script it filters all the rdl files that are available in the given folder.

New-WebserviceProxy : Creates the proxy to connect the reporting server web service.

ListChildren : List all the report in a specified report server folder.

DeleteItem : Delete item method used to delete the specified report.

gc Or Get-Content : used to get the text/data from the file.

CreateReport : used to deploy the report in report server for the specified report. This method is only applicable to report web service 2005. For the report web service 2010 it used the CreateCatalogItem method.

The screen given below can used for reference.




The above script written only for deploying reports that uses the common data source.






Friday, May 8, 2015

Deploy reports files in SSRS (Report Server) using Command Line tools (PowerShell)

In General SSRS .rdl files deployed using the below command line utilities
  • Power-Shell Scripts
  • Rs.exe Scripter (in house tool )  
Deploy SSRS files using PowerShell :

Administrators will use the command line utilities for deploy the SSRS rdl files.

Download the entire script using below link.

DeploSSRS rdl file using PowerShell with Shared Datasource

The script is used to deploy the SSRS rdl to report server.  The prerequisite for deploying reports through powershell is to set the execution policy to unrestricted.

Once Execution policy is set to Unrestricted you can run the script using powers hell.


  • Deployment and the Input parameters.




SQL Server 2005 and 2008 uses the report web service 2005 and the method name is CreateReport. for SQL Server 2008R2 on wards it uses the Report web service 2010 and the method name is CreateCatalogItem

The report shown in the example is using Shared Data source that already created in the system. 







Script  :

<#  
.DESCRIPTION
    Installs an RDL file to SQL Reporting Server using powershell
 
.NOTES
    File Name: DeploySSRS.ps1
    Prerequisite: SSRS 2008/2012/2014, Powershell 2.0
 
.PARAMETERS

     .Reporturl
        The reporturl specifies the SSRS Report manager url.
        Ex: http://bridgequiz:80/ReportServer

     .Reportfilepath
        The Report filepath is used to get the local file path of the report.
        Ex: C:\Users\Malleswara\Documents\Visual Studio 2012\Projects\ssrs\ssrs\StudentMarks.rdl".

    .ReportServerfolder
        The Reportfolder path is used to specify the report server folder in ssrs server.(report manager).
        Ex: "/Reports 2015".

    .Serverversion
        The Serverversion is to sepcify which SSRS version it is using currently in report server.
        Ex: 1) For SQLServer 2005,2008 the report serverversion is http://bridgequiz:80/ReportServer/ReportService2005.asmx?WSDL
            2) for SQLserver 2012 and 2014 the report serverversion is http://bridgequiz:80/ReportServer/ReportService2010.asmx?WSDL

     .RepName
        Name of report wherein the rdl file will be save as in Report Server.
        If this is not specified it will get the name from the file (rdl) exluding the file extension.
#>

function DeploySSRS
(
`
            [Parameter(Position = 0 )]
            [Alias("Reporturl")]
`           [string]$WebServiceUrl="http://bridgequiz:80/ReportServer",

            [Parameter(position = 1 )]
            [Alias("Reportfilepath")]
            [String]$rdlfile="C:\Users\Malleswara\Documents\Visual Studio 2012\Projects\ssrs\ssrs\StudentMarks.rdl",

            [Parameter(position = 2)]
            [Alias("ReportServerfolder")]
            [string]$reportFolder="/Reports 2015",              

    [Parameter(position = 3)]
            [Alias("Serverversion")]
            [string]$reportserverversion="2010",      

            [parameter(position = 4)]
            [Alias("RepName")]
            [string]$ReportName="",

    [Parameter(position = 5)]
    [array]$out

)

    {
                Write-Host "Hosting SSRS RDL File"
       
            # set  report server URL
       
                if ($reportserverversion -eq "2005" )
        {

           $Url = $WebServiceUrl + "/ReportService2005.asmx?WSDL"
        }
        else

        {

             $Url  = $WebServiceUrl + "/ReportService2010.asmx?WSDL"

        }


                #create SSRS proxy

                Write-Host "Creating SSRS Proxy connection to :$Url "

                try
                {

                    $ssrsproxy = New-WebserviceProxy -uri $Url  -useDefaultCredential -Namespace "ReportingWebService"


            Write-Verbose "SSRS Proxy Created Scuessfully"


                }

                catch [System.Exception]
                {

            Write-Verbose "Failed to Create SSRS Proxy "

                            $_.Exception.Message
        
                }

            # set  report name if blank , default will be the filename without extension

            if ($reportname -eq "" )
                        {

                                    $reportname = [System.IO.Path]::GetFilenameWithoutExtension($rdlFile );
             Write-Host " Report name set to $reportname"
           
         }

    try
        {

           $reports = $ssrsproxy.ListChildren("/Reports 2015", $false);

           $currreport = $reports | where { ($_.Name -eq $ReportName) }


         if ($currreport.name -eq $ReportName)
         {
              
                Write-Host "Report already exists on reportserver";
                $ssrsproxy.DeleteItem($reportFolder+"/"+$reportname);
                Write-Host "Report" $reportname "deleted sucessfully"   
         }
        
            
            Write-Host "DeploySSRS Getting file content (byte) of : $rdlFile "

            $byteArray = gc $rdlFile -encoding byte

            $msg = "DeploySSRS Total length: {0}" -f $byteArray.Length

            Write-Host $msg
 
            Write-Host "Uploading to: $reportFolder"
 
            #Call Proxy to upload report

           if ($reportserverversion -eq "2005" )
            {

                 $warnings = $ssrsProxy.CreateReport($reportName,$reportFolder,$true,$byteArray,$null)

            }
            else
            {
                [array]$test
                $ssrsProxy.CreateCatalogItem("Report", $reportname, $reportFolder, $false, $byteArray,$test , [ref]$out);


            }

            if($warnings.Length -eq $null)

                                {

                    Write-Host "report deployed Sucscessfully"
           
                 }

            else
   
                                 {
                                            $warnings | % { Write-Warning " Warning: $_"
                                 }
            }
               
    }
   
        catch [System.IO.IOException]
        {
            $msg = "Error while reading rdl file : '{0}', Message: '{1}'" -f $rdlFile, $_.Exception.Message
            Write-Error $msg
        }
        catch [System.Web.Services.Protocols.SoapException]
        {
            $msg = "Error while uploading rdl file : '{0}', Message: '{1}'" -f $rdlFile, $_.Exception.Detail.InnerText
            Write-Error $msg
        }
 
        }