rs <> "ratshit"

We’ve been using SQL Server Reporting Services for a while now, but hadn’t discovered any easy way to deploy to the Report Server.

A SQL Server Report Template is essentially a large XML file (RDL extension).

This needs to be copied/uploaded to the Report Server Web Service – as well as a Data Source that the report utilises.

While you can deploy reports (RDL) and data sources (DS) from within Visual Studio.NET, this is not practical for many reports / many servers – ie. a bit tedious and fiddly.

&ltjoy&gtI have now discovered the command-line utility RS.EXE as part of Reporting Services !&lt/joy&gt

RS.EXE is essentially used to call script files to perform actions using the Reporting Services Web Service. The script could be viewed as VBA.NET I guess !

The following example explains >

rs -i script_file.rss -s http://server_name/reportserver -u User -p Pwd -v parentFolder=RS_Templates

-i Name of Script File

-s Server Name (web-service URL)

-u User-name for web-service

-p Password for web-service

-v Options > ParentFolder is the “root directory” to be used on Report Server

script_file.rss looks a lot like a VB code module, and must include a Main method (just a bit of code to read thru) >

Dim definition As [Byte]() = Nothing

Dim warnings As Warning() = Nothing

Dim parentPath As String = “/” + parentFolder + “/LeaseReports”

Dim filePath As String = “C:\pvcs\DEV\VLMS\Client\Reports\LeaseReports\”


Public Sub Main()

‘create folder

rs.CreateFolder(parentFolder, “/”, Nothing)





‘. . . (just add to list of reports to deploy)

End Sub


Public Sub CreateDataSource()

‘Define the data source definition.

Dim definition As New DataSourceDefinition()

definition.ConnectString = “data source=SERVERNAME;initial catalog=” + parentFolder

definition.UserName = “USERNAME”

definition.Password = “PASSWORD”

rs.CreateDataSource(name, parentPath, False, definition, Nothing)

End Sub


Public Sub PublishReport(ByVal reportName As String)

Dim stream As FileStream = File.OpenRead(filePath + reportName + “.rdl”)

definition = New [Byte](stream.Length) {}

stream.Read(definition, 0, CInt(stream.Length))


warnings = rs.CreateReport(reportName, parentPath, True, definition, Nothing)

If Not (warnings Is Nothing) Then

Dim warning As Warning

For Each warning In warnings


Next warning


Console.WriteLine(“Report: {0} published successfully with no warnings”, reportName)

End If

End Sub


And so, the deploy of reports is now very-easy. Simply update the script with the NEW reports to be added – and re-run the RS command.

I’ve also got a master script that calls RS.EXE for each server needing to be deployed – UAT, DEV, Prod_Support and Production.


&ltextra&gtI’ve basically taken a script from the sample scripts provided with Reporting Services :

C:\Program Files\Microsoft SQL Server\MSSQL\Reporting Services\Samples\Scripts

…and the Reporting Services command line (RS.EXE) is located >

C:\Program Files\Microsoft SQL Server\80\Tools\Binn



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s