Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
Discover how to create, manage, and deliver interactive reports—not just to print, but to dynamically explore enterprise-level data—with Reporting Services in SQL Server. In this course, author Simon Allardice concentrates on using Report Builder to build and format reports from a variety of data sources, but also shows how to perform basic administration tasks such as granting user access and organizing reports in the Report Manager. Plus, learn how to add interactive sorting and filtering functionality to your reports, and create column and pie charts to better express your data.
Note: These tutorials are applicable to both the 2008 and 2012 versions of SQL Server.
So while it's very easy to create reports that just write out every row in a table, we often want to start grouping things a bit more meaningfully, and that's very easy to do in Reporting Services. And most of this grouping we'll actually do in the report itself rather than writing complex SQL to deal with it. So I am going to open up Report Builder again and create a blank report. The first thing I am going need here is the data source, so I will right-click and add a data source. I am going to connect again AdvertureWorkslight, so I will just give it a short name, AWLT, and this will be embedded in this report.
It is talking to SQL Server. I will click the Build button to start defining this. And the previous example I'd use the Server name dbserver. This is actually the address of my SQL Server 2008 R2 server, which means that using Windows authentication to connect to it, if I click the dropdown here, it will show me the databases that are in that SQL Server, which are the 2008 versions of my AdventureWorks database, along with a few others. But I could just as easily give it a different server address for a different version.
In fact, for me, my address of my SQL 2012 server is this one. So connecting again using my authentication here, if now I click the dropdown box, I will get the AdventureWorks 2012 versions that are installed on that SQL Server. Now, of course this is much more to deal with your organizational setup than it is with Reporting Services, but it's worth pointing out that it's very easy in this Connection window to connect to multiple different sources of data, as long as you're allowed to talk to that source of data. So I will select the AdventureWorksLT version and just test that connection. It looks good.
Click OK, click OK. We have our data source. Step two the dataset. So right- clicking here will add a dataset. This time I am going to go for a list of products. We are going to start grouping these in some meaningful fashion, so I will call this dataset products and it will be embedded in this report. It's going to ask what data source we are using. Well of course it's the one we just defined to AdventureWorksLT. And then I will come down and click the Query Designer button to actually specify the data that I want. So we are talking to that database.
It's showing us all the tables. I am going against the ProductTable. I could just select the checkbox to bring in every single column from that table, but it's good practice to only select the columns that you need. Now for me this time around it's going to be the product name, and I also want to know what category this product is in. Well, if I come down a little bit more in the product table, there is a ProductCatagoryID. This will be a numeric ID, which isn't all that useful, but it's what I am going to start with right now.
If I go ahead and click Run Query, we are going to see the name of our products coming back with this ProductCategoryID number as well, and the idea of course is there's multiple products in a particular category. We don't necessarily know what that category is, but we will get to that. I just want to do some grouping here. So I am going to ahead and click OK and say that that was my dataset. The next thing I need is something on this report that will actually write it out. So what are we trying to do here? Well, let's give it a title first.
I am going to click in here and say that this will be Products Grouped by Category. And because we know there will be multiple rows, we need some kind of repeating region here. I am going to jump up to my Insert tab, and the section we are interested in is the Data Regions. The one I want is the Table. I am clicking the dropdown arrow here; I am going to select Table Widget. The first thing that's going to ask for is what dataset is meant to fuel this table; it of course is the products dataset I just defined. Selecting that, I click Next. And this is where it's asking what fields to show.
And the previous version, what I've done is drag everything into the Value section. This time around what I am going to do is drag Name, as in the product name, into the Value section and Product Category ID into the Row groups section, telling this table I want to start grouping these rows together by the Product category ID. So if I have two rows with that product category of 18, they will be grouped together in that table. And we will see the impact that has visually in just a second. So this is a very simple example, but I like to start simple and build from this.
So I will go ahead and click Next. We now get an option for grouping. There are different visual options you can have where the things are shown beside each other. We have another option here for Blocked, with a subtotal above, Stepped in the subtotal above. It really doesn't matter in our example because we are so simple right now, so you can choose any one that looks visually appealing to you. I am just going to select these Stepped with subtotal above and click Next. Now we have the option of choosing a style. I am actually going to go ahead and click the Generic one, which is essentially style-free; it doesn't have background colors and no particular fonts here.
So with Generic selected, I will click Finish, and it drops in the table into our report. I am going grab the handle on this side and just drag it a little wider here so we have got more room to play with, and then from the Home tab of Report Builder, just click Run. And this is what our table is generating here. Our rows are actually grouped together into these categories, and they are collapsed by default. So we have the little plus box here that I can click and start opening up and seeing the products in that particular category.
Some of the categories only have one product in and some of them have two, some of them have many more. But as you can see, very easy to do, and we are going to see how we start to format this a little later on. However, our first problem is that this category number isn't very helpful, isn't very readable. We would really want to see a name written here rather than a number, but that information--the actual category name--is stored in a separate table. So next, we are going to see how to start to join tables together in Reporting Services.
There are currently no FAQs about SQL Server Reporting Services in Depth.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.