Lesson 1: Creating a Report Model in Model Designer
To generate a model, you need to create a report model project. In this lesson, you will create a report model project using the Business Intelligence Development Studio. A report model project is a container for the model and consists of one or more data source (.ds) files, one or more data source view (.dsv) files, and one or more report model (.smdl) files. Only one data source and data source view can be referenced in an .smdl file. After you create a report model project, you will deploy the report model to your report server, and then use the report model to create a basic report using Report Builder.
Note
For the purposes of this tutorial, you will use the data source view that is automatically generated for you. To learn more about manipulating data source views, see Designing Data Source Views (Analysis Services) and Defining Data Source Views How-to Topics.
To create a Report Model Project in Business Intelligence Development Studio
Click Start, point to All Programs, point to Microsoft SQL Server 2008, and then click SQL Server Business Intelligence Development Studio.
In the Microsoft Visual Studio window, click File, point to New, and then click Project.
Click Report Model Project.
In the Name box, type Adventure Works Model.
Click OK.
To create a data source
In Solution Explorer, right-click Data Sources, and then select Add New Data Source.
The Data Source Wizard opens.
On the Welcome to the Data Source Wizard page, click Next.
On the Select how to define the connection page, verify that Create a data source based on an existing or new connection is selected and the click New.
The Connection Manager dialog box opens.
Note
The Provider drop-down box is grayed out because only SQLClient Data Provider is supported. Model Designer can only generate models based on SQL Server databases.
In the Server name list, select the name of the computer where the AdventureWorks database is stored.
Verify that Use Windows Authentication is selected.
In the Connect to a database area, verify that Select or enter a database name is selected, and then select AdventureWorks from the list.
To verify that the connection works, click Test Connection.
Click OK..
On the Select how to define the connection page, verify that the connection you just created is selected, and then click Next.
On the Completing the Wizard page, verify that AdventureWorks appears in the Data source name box.
Click Finish.
The Data Source Wizard closes, and the AdventureWorks.ds file appears in Solution Explorer. Next, you will create a data source view file.
To create a data source view
In Solution Explorer, right-click the Data Source Views folder and select Add New Data Source View.
The Data Source ViewWizard opens.
On the Welcome to the Data Source View Wizard page, click Next.
On the Select a Data Source page, verify that the AdventureWorks data source you created in the previous procedure is selected.
Click Next.
On the Select Tables and Views page, select all the tables in the Available objects area, and then click the arrow button.
Note
Views can be added to a report model. They are excluded from this tutorial for simplicity of the resulting model.
Click Next.
On the Completing the Wizard page, verify that AdventureWorks appears in the Name box, and then click Finish.
The AdventureWorks.dsv file appears in Solution Explorer. Next, you will create the report model.
To create a report model
In Solution Explorer, right-click Report Models and then select Add New Report Model.
The Report Model Wizard opens.
On the Welcome to the Report Model Wizard page, click Next.
On the Select Data Source View page, verify that the AdventureWorks data source view you created in the previous procedure is selected.
Click Next.
In the Select model language drop-down list of the Select report model generation rules page, select a language for the model.
The language you select tells Model Designer which language-specific code it should use when generating user-friendly names for the tables and columns in your database. After you complete the wizard, you can set the Culture property on the model.
Note
If you select a language other than the default after you change the model generation rules, you will lose any changes you have made to the rules. If you lose your changes, you need to select or clear the check boxes again for each rule that you changed.
Accept the default rules.
Note
By changing the rules used to create the model, you control what is generated.
Click Next.
On the Collect Model Statistics page, verify that the Update model statistics before generating option is selected, and then click Next.
Note
To create a report model, the Report Model wizard collects statistics about the number of unique instances for each field and their cardinality information. Collecting these statistics does not affect your database statistics or performance.
On the Completing the Wizard page, verify that AdventureWorks appears in the Name box, and then click Run.
The report model is created.
When the wizard is finished, click Finish.
The AdventureWorks.smdl file appears in Solution Explorer. You have successfully created a report model. In the next procedure, you will explore the model.
To explore the report model
In the Model pane, select the Customer entity.
Note
The report model consists of multiple entities. All entities, and any folders that you create, are listed in the Model pane. The Model pane is also called the Tree view.
View the center pane. The contents of the Customer entity appear. The attributes include: #Customers, #CustomerID, Account Number, Customer Type, and Modified Date.
Note
The center pane is called the List view. The attributes, roles, and perspectives contained within a selected entity are displayed in List view.
In the List view, select the #Customers attribute, and then view the contents of the Properties window.
Note
If the Properties window is not displayed, on the View menu, select Properties Window.
In the List view, select the Customer Type attribute, and then view the contents of the Properties window.
In the List view, select the Sales Order Headers role, and then view the contents of the Properties window.
On the File menu, click Save All.
Next, you will deploy the report model to the report server.
To deploy the report model
On the Project menu, click AdventureWorks Model Properties.
Note
The default deployment location is the local server at https://localhost/reportserver and the default deployment location for a model is in the /Models folder located off the root of the report server. If these are not the deployment properties you want to use, specify the properties specific to your environment.
After you confirm the deployment properties that you want to use, click OK.
On the Build menu, click Deploy AdventureWorks Model.
If the deployment is successful, a Deploy succeeded message is displayed in the Output window. To view the Output window, on the View menu, click Output. If the deployment fails, you need to troubleshoot the reported error.
In the next procedure, you will test the report model in Report Builder.
To use the model in Report Builder
Open your browser.
In the Address bar, type https://localhost/reports.
The Home page for SQL Server Reporting Services opens.
On the Report Manager toolbar, click Report Builder.
In the Getting Started pane, select AdventureWorks and then click OK.
In the Entities list, select Sales Order Header.
From the Entities list, drag the Sales Person entity to the design area.
Notice that the Sales Person National ID Number and Commission Pct fields are added to the design area.
In the Fields list, double-click Total Total Due.
Notice that the Total Total Due field is not formatted as a monetary value.
To see the results of your query, click Run Report.
On the File menu, click Exit.
You do not need to save the report.
Next Steps
In the next lesson, you will add a description to the model that you just created. See Lesson 2: Adding a Description to a Model.
See Also