How to Script Reporting Services (Using the RS Utility)


The RS utility is a scripting utility that enables access to Reporting Services functionality using Visual Basic .NET scripts. In scripts, you can define classes and use other object-oriented functionality of Visual Basic .NET.

By default, the RS utility is installed in the C:\Program Files\Microsoft SQL Server\90\Tools\Binn directory. SSRS comes with four sample scripts (located at C:\Program Files\Microsoft SQL Server\90\Samples\Reporting Services\Script Samples ): deploy a report, cancel a job, set security on an item (report, folder, and so on), and change SSRS properties. You can dissect and modify those scripts to fit scenarios at hand. Scripting is a convenient way to automate repetitive administrative tasks or tasks that apply to a group of items.

Executing the " rs /? " command yields the following usage direction:

 Microsoft (R) Reporting Services RS Version 9.00.1399.00 x86 Executes script file contents against the specified Report Server. RS -i inputfile -s serverURL [-u username] [-p password]    [-l timeout] [-b] [-e endpoint] [-v var=value] [-t]         -i  inputfile   Script file to execute         -s  serverURL   URL (including server and vroot) to execute                         script against.         -u  username    User name used to log in to the server.         -p  password    Password used to log in to the server.         -e  endpoint    Web service endpoint to use with the script.                         Options are:                         Exec2005 - The ReportExecution2005 endpoint                         Mgmt2005 - The ReportService2005 endpoint                         Mgmt2000 - (Deprecated) The ReportService endpoint         -l  timeout     Number of seconds before the connection to the                         server times out. Default is 60 seconds and 0 is                         infinite time out.         -b              Run as a batch and rollback if commands fail         -v  var=value   Variables and values to pass to the script         -t  trace       Include trace information in error message 

The following sample script gets a list of extensions registered with Reporting Services and, as a bonus, outputs the Report Server version and edition.

 Public Sub Main()     Dim Extensions As Extension() =                                      rs.ListExtensions(ExtensionTypeEnum.All)     Console.WriteLine("Report Server Version Number:" +  rs.ServerInfoHeaderValue.ReportServerVersionNumber)     Console.WriteLine("Report Server Edition:" +  rs.ServerInfoHeaderValue.ReportServerEdition)     Dim Ext As Extension     Dim Type As String     Console.WriteLine("Type      Name")     For Each Ext In  Extensions          Select Ext.ExtensionType                         Case ExtensionTypeEnum.Delivery                         Type = "Delivery"                 Case ExtensionTypeEnum.Render                         Type = "Render  "         Case ExtensionTypeEnum.Data                         Type = "Data    "                  Case Else                         Type = "Other   "         End Select         Console.WriteLine(Type + " " + Ext.Name)     Next End Sub 

ReportServerVersionNumber and ReportServerEdition are properties of Reporting Services. You need to call Reporting Services before the properties are set. If you place this call after you access Reporting Services properties, those properties will be empty. This is what you are doing in line Extension()=rs.ListExtensions(ExtensionTypeEnum.All) .

The scripting utility provides an internal reference to Reporting Services through the rs object , which is ready to be used in scripts without an explicit instance creation. The command to execute the script might look like the following:

 rs -iRsUtilTest.rss -shttp://localhost/ReportServer 



Microsoft SQL Server 2005 Reporting Services
Microsoft SQL Server 2005 Reporting Services
ISBN: 0672327996
EAN: 2147483647
Year: 2004
Pages: 254

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net