If this is your first time creating an SSRS report, then this is the right article for you. Below is a step-by-step guide that will help you to create, deploy and view your first report using SQL Server Reporting Services 2008:
Environment Check
Assuming the following are installed and already configured on your machine:- Installed SQL Server 2008 R2
- Installed AdventureWork Sample Databases
(You can visit Microsoft website to download and install it:
http://msftdbprodsamples.codeplex.com/releases/view/55926
We are using it in this case as a sample database. However, you can write any SQL statement on one of your pre-installed Databases) - Installed SQL Server 2008 Reporting Services
(If you have not done this, visit this post: SSRS 2008 Installation Guide) - Both SQL Server and Reporting Services are installed on the same machine (localhost)
1. Open SQL Server Business Intelligence Development Studio (BIDS) by going to:
Start > All Programs > Microsoft 2008 R2 > BIDS
2. From the menu, choose File > New > Projects
3. Choose the right template: Report Server Project and type in name of the Project:
4. If this is your first time creating a report, then we do need to setup the path where some of the reports are stored while deploying. (We only need to do this once) So, right click on the project name from your Solution Explorer window (on the right side) and choose Properties.
5. I would normally leave the settings as default EXCEPT you need to add the value for parameter TargetServerURL which is blank:
6. Normally, the Report Server URL is: http://localhost/ReportServer
You can check this by going to: Start > All Programs > SQL Server 2008 R2 > Configuration Tools > Reporting Services Configuration Manager. Then, from left menu choose Web Sever URL and under Report Server Web Service URL, you will find the address which is setup. You can always replace the long ugly machine name with localhost:
7. Type in the Server URL and click OK:
8. Now, we begin to add Reports to our project. To do this, right click on Reports folder and choose Add > New Item:
9. Type in the name of your report: ContactList.rdl and click Add
10. Report Wizard will start. Although, you can create report manually without wizards, for the purpose of this first exercise we continue with the wizard. Click Next:
11. Every report need a DataSource to know which database to connect to. As this is the first time, we have to create this. Click on Edit:
12. Type in Server Name: localhost. I have setup the SQL Server to accept Window Authentication. Otherwise, enter SQL Server Authentication:
13. Choose the database that you want to work with and click OK to finish:
14. Now that we have created the connection string, click on Next to continue (note that you also tick the box Make this a shared data source to use for future reports):
15. In the next step, it will ask to to type in the Query String. There are two ways of doing this, either use Query Builder or write in your own code. I prefer the later, so I have opened SSMS and wrote my select statement which return the result that I have to use in my report. I will also run it to make sure the syntax is connect. Copy the code to the clipboard:
16. Page the code in the Query String and click Next:
1: SELECT
2: Title,
3: FirstName,
4: LastName,
5: EmailAddress,
6: Phone
7: FROM Person.Contact
8: WHERE Title IS NOT NULL
17. Depending on the report choose the type. This is a simple basic report so we are going to use Tabular. Click Next:
18. In this step, the wizard allows you to do Grouping but for the purpose of this exercise, we will have a simple report that return lost of all names. Also, we have already specified the columns that we want in our SELECT query; therefore, we want to select all the available fields and click the Details button to move them to the Details section:
19. We can see all fields are in the Details section. Click on Finish:
20. You can type in or change the name of the report and click Finish to end:
21. We can see the report is now created. To view the report click on Preview tab:
22. The preview Tab will run and render the report to see the outcome result:
23. So, now that we have created the report and preview it, we can need to Deploy it to the Report Server so that it can be viewed and accessed by end-users. To do this, right click on the report file (ContactList.rdl) and choose Deploy:
24. Remember that we have to setup the Target Report Server URL correctly before deploying. If all is done correctly, we will see the successful message in the Output result dialog box. This is a confirmation that the report has successfully built, deployed and ready to be viewed:
25. To view the report which has just been deployed, open IE browser and type in: http://localhost/Reports
This is the address where all Reports are deployed and can be accessed by end-user. We can also see that reports are in a Folder structure similar to Window Files. Click on MyFirstReport folder:
26. And finally to view the report, click on ContactList:
27. Here is the report displayed on your web-browser:
28. Finally, a very useful feature of SSRS reports is the ability to export them into PDF, Excel, or Word:
Comments
Post a Comment