Microsoft SQL Reporting Services – Running a Report from the Command Line
Posted on 2005-01-07 13:29 iCeSnaker 阅读(1742) 评论(0) 编辑 收藏 举报Author: Ajit Mhaiskar
Published: 1/6/2005
Introduction
I recently ran into a need to run a report in SQL reporting services from the command line. The Report took four (4) input parameters and I had to export it to Microsoft® Excel and save it to disk. I had to rummage through the product documentation and the Microsoft® SQL Reporting newsgroup to get this right. For running reports from the command line, SQL Reporting services provide a utility called “rs utility”.
The rs Utility
The rs utility is a script host that processes script you provide in an input file. You can define scripts to administer a report server, copy report server database content to another database, publish reports, and so forth. The script must be written in Microsoft Visual Basic® .NET code, and stored in a Unicode or UTF-8 text file with a .rss file extension. You cannot debug scripts with the rs utility. To debug a script, run the code from within Visual Studio.
To run the tool, you must be a local administrator on the computer that has the report server instance you are running the script against. There are some script samples provided with the Reporting Services installation and the samples are located in the following directory in your Reporting Services installation: <Reporting Services>\Samples\Scripts
“Run Report” Script
The following script is meant to run the report by passing it parameters and saving the output to Excel. Out of the four (4) parameters required by the report, the values for three of the parameters are hard-coded in the script file. The fourth parameter expects a value to be provided at runtime during the running of the script.
















































Running the Script
To run the script, and pass the fourth parameter (MonthParameter) at runtime, issue the following command at the command prompt –

The -v flag above declares a global variable called MonthParameter and initializes it with the value “9”. This global variable is used in the script to set value to the Month parameter as parameters(3).Value = MonthParameter
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix