SQL Server Reporting Services (SSRS) is part of Microsoft SQL Server services since version 2000. If you are an ordinary user with a basic knowledge of SQL, this article will help you in creating your first SSRS report.
自2000版以来,SQL Server Reporting Services(SSRS)是Microsoft SQL Server服务的一部分。如果您是具有SQL基本知识的普通用户,则本文将帮助您创建第一个SSRS报告。
创建SSRS报告的要求 (Requirements for creating a SSRS report)
Before you begin using SSRS and creating reports you must have:
在开始使用SSRS和创建报告之前,您必须具有:
- Microsoft SQL Server 2014 database engine Microsoft SQL Server 2014数据库引擎
- SQL Server 2014 reporting service (SSRS) SQL Server 2014报告服务(SSRS)
- SQL Server data tools SQL Server数据工具
- AdventureWorks2012 database is used for this article, as AdventureWorks2012数据库作为data source. 数据源 。
创建报告服务器项目 (Create a report server project)
The first thing to do is to create a report server project because we will need this later for saving report definition files and any other files that you need for creating SSRS reports.
要做的第一件事是创建报告服务器项目,因为稍后我们将需要它来保存报告定义文件以及创建SSRS报告所需的任何其他文件。
- SQL Server Data Tools. Click on the SQL Server数据工具 。 单击File menu, find 文件菜单,找到New and then 新建 ,然后找到Project.项目 。
- Business Intelligence. Business Intelligence 。
- Reporting Services and then Reporting Services ,然后单击Report Server Project. Report Server Project 。
- Report test in 名称”中键入Name “报告测试”
- OK to finish. 确定”完成。
创建一个新的报告定义文件 (Create a new report definition file)
- Solution Explorer, and then right-click on the 解决方案资源管理器” ,然后右键单击“ Reports folder. In the 报告”文件夹。 在“ Add section click 添加”部分中,单击“ New Item. 新建项目” 。
- Add New Item, click 添加新项 ”窗口中,单击Report. “报告” 。
- Design view you define your report layout, and in the 设计视图中,您可以定义报告布局,在Preview view you can run your report. 预览视图中,您可以运行报告。
定义数据源和数据集 (Defining data source and dataset)
Setting up a connection
建立连接
In order to retrieve data from a database or from some other resource, you will need to define the data source. In the following section, you will see how you can define the data source. We will use AdventureWorks2012 database as an example.
为了从数据库或其他资源中检索数据,您将需要定义数据源。 在下一节中,您将看到如何定义数据源。 我们将以AdventureWorks2012数据库为例。
- View menu find and click Report Data, then 查看”菜单中,找到并单击“报告数据”,然后单击“ New and after that 新建 ”,然后单击该Data Source数据源。
- Type AdventureWorks2012 in the field Name
- 在名称字段中输入AdventureWorks2012
- Embedded connection 嵌入式连接
- Microsoft SQL Server Microsoft SQL Server
- Connection string field type: 连接字符串”字段中,输入: