SQL Server Reporting Service - Deployment by command line

Chinese version: http://www.cnblogs.com/WilsonWu/archive/2009/02/19/1394198.html

Some times when we use the SQL Server Reporting Service will get the same problem, if we have a product constituted by some reports, and there is a new release will be published, we want to get a better way instead of give are RDL files to users directly. actually, SQL Server Reporting already has a tool named RS.exe to help us do some works such as deployment by command line. and today I will introduce main functions in this RS.exe tool:

At first, we use –? to get help information like below:

D:\RS>rs -? 
Microsoft (R) Reporting Services RS 
Version 10.0.1600.22 ((SQL_PreRelease).080709-1414 ) 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 
        -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

 

In fact, that is not hard to understand, only the “-i” parameter maybe has some questions, all right, the “-i” parameter need a script that can run some code to do our work, the script can be wrote by VS.NET, and I have got some information for the script here. at first you must go to the http://www.codeplex.com/MSFTRSProdSamples site to get a sample package, and this have not include into SQL Server install package. after install it go to your SQL Server location like C:\Program Files\Microsoft SQL Server\90\Samples\Reporting Services, you can see a folder named “Script Samples”, then open it and find the “PublishSampleReports.rss” file like below:

 

'============================================================================= 
'  File:      PublishSampleReports.rss 

'  Summary:  Demonstrates a script that can be used with RS.exe to 
'         publish the sample reports that ship with Reporting Services. 

'--------------------------------------------------------------------- 
' This file is part of Microsoft SQL Server Code Samples. 

'  Copyright (C) Microsoft Corporation.  All rights reserved. 

' This source code is intended only as a supplement to Microsoft 
' Development Tools and/or on-line documentation.  See these other 
' materials for detailed information regarding Microsoft code samples. 

' THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 
' KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 
' IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 
' PARTICULAR PURPOSE. 
'============================================================================= 

' 1.0 Documentation 

' Read the following in order to familiarize yourself with the sample script. 

' 1.1 Overview 

' This sample script uses a script file (.rss) and the script environment to run 
' Web service operations on a specified report server. The script creates a folder 
' that you specify as a command-prompt variable using the 杤 switch, and then 
' publishes the sample reports that ship with Reporting Services to a report server. 
' Depending on the location of your sample reports, you may need to modify the 
' value of the filePath variable, which references the path to your sample reports. 

' 1.2 Script Variables 

' Variables that are passed on the command line with the -v switch: 

' (a) parentFolder - corresponds to the folder that the script creates and uses 
'     to contain your published reports 

' 1.3 Sample Command Lines 


' 1.3.1 Use the script to publish the sample reports to an AdventureWorks Sample Reports folder. 

'       rs -i PublishSampleReports.rss -s http://myserver/reportserver 


Dim definition As [Byte]() = Nothing 
Dim warnings As Warning() = Nothing 
Dim parentFolder As String = "AdventureWorks Sample Reports" 
Dim parentPath As String = "/" + parentFolder 
Dim filePath As String = "C:\Program Files\Microsoft SQL Server\90\Samples\Reporting Services\Report Samples\AdventureWorks Sample Reports\" 

Public Sub Main()Sub Main() 

    rs.Credentials = System.Net.CredentialCache.DefaultCredentials 
    'Create the parent folder 
    Try 
        rs.CreateFolder(parentFolder, "/", Nothing) 
        Console.WriteLine("Parent folder {0} created successfully", parentFolder) 
    Catch e As Exception 
        Console.WriteLine(e.Message) 
    End Try 

    'Create the AdventureWorks shared data source 
    CreateSampleDataSource("AdventureWorks", "SQL", "data source=(local);initial catalog=AdventureWorks") 
    CreateSampleDataSource("AdventureWorksDW", "OLEDB-MD", _ 
        "data source=localhost;initial catalog=Adventure Works DW") 

    'Publish the sample reports 
    PublishReport("Company Sales") 
    PublishReport("Employee Sales Summary") 
    PublishReport("Product Catalog") 
    PublishReport("Product Line Sales") 
    PublishReport("Sales Order Detail") 
    PublishReport("Territory Sales Drilldown") 

End Sub 

Public Sub CreateSampleDataSource()Sub CreateSampleDataSource(name As String, extension As String, connectionString As String) 
    'Define the data source definition. 
    Dim definition As New DataSourceDefinition() 
    definition.CredentialRetrieval = CredentialRetrievalEnum.Integrated 
    definition.ConnectString = connectionString 
    definition.Enabled = True 
    definition.EnabledSpecified = True 
    definition.Extension = extension 
    definition.ImpersonateUser = False 
    definition.ImpersonateUserSpecified = True 
    'Use the default prompt string. 
    definition.Prompt = Nothing 
    definition.WindowsCredentials = False 

Try 
    rs.CreateDataSource(name, parentPath, False, definition, Nothing) 
    Console.WriteLine("Data source {0} created successfully", name) 

Catch e As Exception 
    Console.WriteLine(e.Message) 
End Try 
End Sub 

Public Sub PublishReport()Sub PublishReport(ByVal reportName As String) 
    Try 
        Dim stream As FileStream = File.OpenRead(filePath + reportName + ".rdl") 
        definition = New [Byte](stream.Length) {} 
        stream.Read(definition, 0, CInt(stream.Length)) 
        stream.Close() 

    Catch e As IOException 
        Console.WriteLine(e.Message) 
    End Try 

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

        If Not (warnings Is Nothing) Then 
            Dim warning As Warning 
            For Each warning In warnings 
                Console.WriteLine(warning.Message) 
            Next warning 

        Else 
            Console.WriteLine("Report: {0} published successfully with no warnings", reportName) 
        End If 

    Catch e As Exception 
        Console.WriteLine(e.Message) 
    End Try 
End Sub 

 

Except some RS server code, we can get all clear method for Upload report or configuration Data Sources, then you can use them into your own script.

For example:

RS -i "PublishReports.rss" -s "http://[ReportServer]/ReportServer/"

Use above command you can deploy your reports easily.

In next post I will share some best practice to use RS.exe deploy TFS reports.

Thanks!

时间: 2024-07-31 23:05:09

SQL Server Reporting Service - Deployment by command line的相关文章

SQL Server Reporting Service - 命令行部署脚本介绍

首先应公司老总要求写了英文版: http://www.cnblogs.com/WilsonWu/archive/2009/02/19/1394200.html 英文不好别笑话. 进入正题! 使用 SQL Server Reporting Service 的朋友应该都会遇到与此类似的问题, 尤其是在产品中, 比如我们有若干个报表形成的一个产品, 这些报表是需要用户部署在报表服务器上的才能使用的, 我们可以只给用户 RDL 报表文件和一个文档教程, 让他们自己上传, 自己配置数据源等等, 但是这样也

SQL Server Reporting Service - 一步部署 TFS 项目报表

上次介绍了 SQL Server Reporting Service 命令行部署报表的基本内容, 利用这些知识我们可以轻松的部署报表, 然而在 TFS 中, 每个项目都有它对应的报表, 这些报表如果要一个个的更新也是件痛苦的事情, 现在我也遇到了这个问题, 针对 TFS 开发了两张报表, 但是如何将这些报表应用到所有项目上呢? 结合之前的部署脚本知识, 我们可以使用下面方法实现: 首先建立一个批处理文件ImportWIT.bat, 用来更新某个项目的Work Item定义文件:   @ECHO 

[收藏]利用SQL Server Reporting Services 从应用程序生成用户友好的报表

server|services|程序 利用 SQL Server Reporting Services 从应用程序生成用户友好的报表 发布日期: 09/03/2004 | 更新日期: 09/03/2004John C. Hancock   http://www.microsoft.com/china/msdn/library/data/sqlserver/SQLServerReportServ.mspx本文讨论:•Reporting•设计和部署报表•使用 Reporting Services 的

SSRS (SQL Server Report Service) 在IE9, IE10下显示不全的解决办法

原文:SSRS (SQL Server Report Service) 在IE9, IE10下显示不全的解决办法 在做项目的过程中遇到SSRS与IE9, IE10不兼容的情况,具体表现为报表页面在IE9 和 IE10下面只显示三分之一,靠左显示,下方有滚动条,右三分之二为空白.查看源代码后发现,上面一个<tr>里只有一个<td>,并colspan=3, 下面报表内容区域的<tr>有三个<td>但前两个是hidden的.最初是想把表格结构调整下,去掉前面hid

充分利用SQL Server Reporting Services图表

本文适用于Microsoft SQL Server 2005 Reporting Services 简介 本白皮书讲述如何在 Microsoft SQL Server Reporting Services 报表中设计图表.本文分为几部分 并引用特定的报表示例:它们包含在示例项目下载中. 第一部分为数据准备,此部分主要包括有关准备数据的特定信息.技巧和见解.第二部分为图表标签 ,此部分讲述如何应用标签设置来改进图表和控制视觉外观和效果. 示例图表和报表部分讲述如何充分利用 SQL Server R

tfs2010用户-SQL Server Reporting Services 涉及到用户列表都无法加载

问题描述 SQL Server Reporting Services 涉及到用户列表都无法加载 解决方案 http://blog.csdn.net/hadstj/article/details/11178971

微软Sql server analysis service数据挖掘技术

原文:微软Sql server analysis service数据挖掘技术 最新在一个项目中要求用到微软SSAS中的数据挖掘功能,虽然以前做项目的时候也经常用到SSAS中的多维数据集 (就是CUBE),但是始终没有对SSAS中的数据挖掘功能进行过了解.所以借着项目需求这股东风最近了解了下SSAS的数据挖掘,这里先写一篇博客做一个简要的归纳.   说到数据挖掘,我们首先需要知道SSAS数据挖掘能干什么,为什么需要进行数据挖掘.我们先来看一个例子假设我们数据库中现在有一张表叫CustomersBo

基于SQL Server 2008 Service B“.NET研究”roker构建企业级消息系统

1.引言 Microsoft 在SQL Server 2005引入了服务代理 (Service Broker 简称SSB) 为技术支持代理设计模式和面向消息的中间件 (MOM) 的原则.Service Broker在SQL Server 2008上得到完善, SQL Server Service Broker 为消息和队列应用程序提供 SQL Server 数据库引擎本机支持. 这使开发人员可以轻松地创建使用数据库引擎组件在完全不同的数据库之间进行通信的复杂应用程序.开发人员可以使用 Servi

一起谈.NET技术,基于SQL Server 2008 Service Broker构建企业级消息系统

1.引言 Microsoft 在SQL Server 2005引入了服务代理 (Service Broker 简称SSB) 为技术支持代理设计模式和面向消息的中间件 (MOM) 的原则.Service Broker在SQL Server 2008上得到完善, SQL Server Service Broker 为消息和队列应用程序提供 SQL Server 数据库引擎本机支持. 这使开发人员可以轻松地创建使用数据库引擎组件在完全不同的数据库之间进行通信的复杂应用程序.开发人员可以使用 Servi