Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
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 going from the end of the last example, we have some grouping going on here, but it's not as useful as it could be. So if I were to look at the underlying table definition, the issue that we have is when we are looking at the information for any particular product we are getting a name--say, Water Bottle, 30 OZ--but we are also getting this ProductCategoryID. It's just a number, 32. And what we want to do is take it to a separate table, ProductCategory, where we can take that number of 32 and actually get the name of the category, in this case Bottles And Cages.
Well, the great thing is, as long as there's a proper relationship defined in the database--and there is here--it's very easy for us to focus on what we want, which is the name of the product and the name of the category. And actually, in this case, we can let Report Builder pretty much figure everything else out. So back in Report Builder, I'm going to switch back into Design view. And really what I want to do here is back things a bit and go back to the dataset. So I actually don't need this table anymore.
So I'm going to delete it. Now to make sure I delete it properly, I first click somewhere inside it and then when the gray bars appear, I'm going to select the one at the very top-left corner, which will give me the entire selected table, and then I just delete that. Now what I want to do is redefine the data set. So I'm just going to double-click the data set name to open that back out. We don't need to change anything about the data source, but we do need to change something about the query. I could manually change the select statement, but I'm just going to go back into the Query Designer. It's still showing me my results from the previous time.
I'm just going to hide those by clicking this button over here. And we just want to focus on the information that we are interested in, which really, for us, is the name in the Product table, I don't really care about ProductCategory ID myself, and then from the ProductCategory table, the name of that. Now, Report Builder is actually smart enough to know that if we have two fields called Name it's not going to work very well. There be a conflict there, so it will internally rename them as Product Name and Product Category Name, and it knows that there's a conflict there.
So how is this going to work? If you've written SQL, you know you have to define the join statement yourself, how these two tables are interrelated. But in fact, a lot of that is being done successfully for us. I can test this by clicking Run Query. And what I'm getting here is the Product Name and the actual ProductCategory Name. And as I come down a little bit further, I'm getting different categories with different products. Now, if you're someone is used to writing SQL, you might be thinking, hang on the second; isn't there a bit of a conflict going on here? Well, let's find out.
Because just by selecting those fields, I'm and become up to the top here and click the Edit as Text button, which will show me the actual SQL statement. And what I'll see here is we are selecting the name from the product table as Product Name, and selecting the name from the category table as ProductCategory Name, and it's generated the inner join statement that joins these two tables together. You see, the query designer here will do a great job of detecting foreign keys in your database as long as your actual database has been well defined. And also, if I untoggle this Edit as Text button, what we want to make sure is that this Auto Detect button in the Relationship section is highlighted, meaning it's selected.
It's trying to detect the foreign keys, and it will do really good job of that. If the relationships you trying to describe in your query are not actually defined in the database, or there's something non-standard, you will have to write the joins yourself. So I'm going to click OK and let's say that is our dataset. And now I want another table, so over to the Insert tab and down to Table Wizard, we'll choose that data set, click Next. Product Name is what our Value is, and ProductCategory Name is what we want to group by.
Click Next. And it doesn't really matter which option we chose here. I'm just going to leave the default, click Next again, and I'll select Generic so we don't have any colors or fonts to worry about, and Finish, and just drag this a little wider. Then up on the Home tab, click the Run button and let's check it out. Now we actually have the name of the category, so under Chains we see the one Chain entry. Under Caps we see the AWC Logo Cap entry. So it's already become a lot more readable, a lot more meaningful, and there's a few missing pieces to it.
So next, let's see how to manipulate the visual layout of this table.
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.