SQL Server Reporting Services Data Bulletin.book - Square D

30 downloads 620 Views 2MB Size Report
May 2, 2013 ... NET code and have access to the entire SSRS API and. SSRS web ... Here's a step-by-step example of using the RS command line utility as.
Microsoft® SQL Server Reporting Services – Automating Report Deployment

Data Bulletin 8000DB1301 May 2, 2013

By: Richard Witucki, Solutions Specialist and David Vlaming, Solutions Architect Schneider Electric Industrial Solutions & Services

8000DB1301 05/2013

Introduction

Microsoft® SQL Server Reporting Services – Automating Report Deployment

Deploying reports that are created by a third party can be automated using a command line utility that is included with SQL Server Reporting Services (SSRS). This document describes this process.

Automating SSRS Deployment Sample Automated Workflow

While reports can be deployed manually using SQL Server Business Intelligence Development Studio, the deployment of the reports can be simplified and automated. An example workflow might be: 1. Several reports are developed remotely. These can be new reports or modified reports 2. The reports (the RDL files) are emailed to the customer (or by some other means) 3. The customer moves the files into a folder on the Report Server 4. A script is run to deploy the reports

RS Command Line Utility & Reporting Services Script

Microsoft® provides a Reporting Services command line utility named RS.EXE that works with a Reporting Services Script (RSS). These scripts are written in VB.NET code and have access to the entire SSRS API and SSRS web service methods. These scripts can be used to automate the deployment of the SSRS reports in a repeatable fashion. The following is an example of the RS utility command:

rs -i PublishReports.rss -s http://server/Reportserver -v ReportFolder="Line 1" -v Overwrite=false The RS utility uses the report server specified by the ‘-s’ switch and processes the commands from the input file as specified by the ‘-i’ switch. Additional variables accessible by the script are specified by the ‘-v’ switch. In this example, the parameters passed to the RS utility are: Input File: PublishReports.rss Report Server: http://server/Reportserver Variables: ReportFolder="Line 1" Overwrite=false In this case, commands specific to SSRS that are called in the PublishReports.rss script act upon the report server http://server/Reportserver using the variable ReportFolder="Line 1" and Overwrite=false that is passed to it.

The URL used on the command line will be specific to the report server that you are using. These URLs can be verified in the Reporting Services Configuration Manager as shown in Figures 1 and 2. Note that you may need to use the “Run As Administrator” option in order to use the Configuration Manager.

© 2013 Schneider Electric All Rights Reserved

3

Microsoft® SQL Server Reporting Services – Automating Report Deployment

8000DB1301 05/2013

Figure 1: Where to find and/or change the URL for the Report Server Web Service, used when running the script

Figure 2: Where to find and/or change the URL for the Report Manager

4

© 2013 Schneider Electric All Rights Reserved

8000DB1301 05/2013

Microsoft® SQL Server Reporting Services – Automating Report Deployment

Specifically, this command uses the PublishReports.rss script to find each SSRS report (file of type RDL) in the current folder and deploy it to the Line 1 folder located on the Home page of the report server. If the variable Overwrite is set to true, any existing reports with the same name are overwritten. The value for Reportfolder can be any valid folder under the ‘Home’ page of the report server. For example ReportFolder="Line 1/Machine 5” represents the ‘Machine 5’ folder under the ‘Line 1’ folder of the ‘Home’ page. The Overwrite variable can be one of two Boolean values—True or False— and is not case sensitive. An example of a valid variable/value pair is Overwrite=True. Make sure the Reportfolder and Overwrite variables are entered on the command line or an error will result.

Use Shared Data Sources

A report data source specifies a name and the connection to the data. A report can include an embedded data source specific to the report or can use a shared data source. A shared data source describes the actual connection data but is stored separate from the report. It can be used across multiple reports and subscriptions. A shared data source is still referenced by name but since it is not embedded in the report, the developer does not need to know its specifics (name of the database, the method for authentication, etc). In the report, simply specify the shared data source’s name, and you can upload the reports to the customer’s SSRS Report Server without modifications.

Example

Here’s a step-by-step example of using the RS command line utility as described. 1. Open the http://server/Reports Report Manager portal as shown in Figure 3. Figure 3: Home page of the Report Server

© 2013 Schneider Electric All Rights Reserved

5

Microsoft® SQL Server Reporting Services – Automating Report Deployment

8000DB1301 05/2013

2. Drill down into the ‘Line 1’ folder. Notice that this folder is empty (see Figure 4). Figure 4: 'Line 1' folder is empty

3. Copy the report files into a directory on the same computer as the Report Server. In this example, the directory’s name is ‘C:\test’. Figure 5 shows the contents of this directory after issuing a ‘dir’ command. Figure 5: Directory listing of Reports (RDL files)

4. Open a Command Prompt using a logon with the appropriate credentials to deploy reports. You may need to open the command prompt using the “Run As Administrator” option. 5. Change to the ‘c:\test’ directory. 6. Execute the following command:

rs -i PublishReports.rss -s http://server/Reportserver -v reportFolder="Line 1" -v Overwrite=false The ‘PublishReports.rss’ script must reside in the same directory where the RS utility is executed, in this example, the ‘c:\test’ directory.

6

© 2013 Schneider Electric All Rights Reserved

8000DB1301 05/2013

Microsoft® SQL Server Reporting Services – Automating Report Deployment

7. Notice the status of each report and the overall status is displayed in this window. Figure 6 shows an example of the RS command successfully executing. Figure 6: RS command successfully executed

8. Refresh the ‘Line 1’ folder on the Report Server. You should see a similar listing to that shown in Figure 7. Figure 7: 'Line 1' Folder after automated deployment

9. Repeating step 6 without removing the reports from the Report Server will result in multiple errors (one per report). 10. Repeating step 6 with the following command will result in reports being overwritten. Notice that the Overwrite parameter has been set to True.

rs -i publishreports.rss -s http://server/reportserver -v reportfolder="line 1" -v overwrite=true

© 2013 Schneider Electric All Rights Reserved

7

Microsoft® SQL Server Reporting Services – Automating Report Deployment

8000DB1301 05/2013

Figure 8: PublishReports.rss

8

© 2013 Schneider Electric All Rights Reserved

8000DB1301 05/2013

© 2013 Schneider Electric All Rights Reserved

Microsoft® SQL Server Reporting Services – Automating Report Deployment

9

Microsoft® SQL Server Reporting Services – Automating Report Deployment

Schneider Electric USA, Inc. 8001 Knightdale Blvd. Knightdale, NC 27545 1-888-778-2733 www.schneider-electric.com

10

8000DB1301 05/2013

Electrical equipment should be installed, operated, serviced, and maintained only by qualified personnel. No responsibility is assumed by Schneider Electric for any consequences arising out of the use of this material. Square D™ and Schneider Electric™ are trademarks or registered trademarks of Schneider Electric. Other trademarks used herein are the property of their respective owners. © 2013 Schneider Electric All Rights Reserved

Suggest Documents