Skip to main content
A newer version of this page is available. .

Bind a Report to a SQL Database

  • 2 minutes to read

This tutorial describes how to bind a report to a SQL database.

Create a Data Model and Report

  1. Define data models that obtain the data from your data providers. For this tutorial, prepare a data model connected to a SQL database.

  2. Open an existing report or create a new report as described in the Create and Customize Reports document to get started.

Bind the Report to Data

To obtain a report’s dynamic data from an external data source, do the following:

  1. Click the main menu button and select Add Data Source to create a new data source.

    report-server-menu-add-sql-data-source

  2. On the first page of the invoked Data Source Wizard, select a SQL data model and click Next to proceed.

  3. On the next page, choose tables, views and/or stored procedures to add to the data source. You can also create custom queries. To do this, click the Queries category’s plus button.

    In the invoked Query Builder, add data tables to the query and join them based on a key column.

    report-server-data-source-wizard-query-builder

    Note

    If the Custom SQL Query Execution Mode option is set to Execute SELECT Statements Only or Execute All in the General Settings window, you can write a custom SQL query instead of constructing it in the Query Builder. See Write a Custom SQL Query for more information.

  4. Specify key fields to define master-detail relationships between queries. Click the plus button next to the master query, choose the detail query to add a new relationship and specify the relationship condition as shown in the following image:

  5. Click Finish to complete the wizard.

View the Result

The Field List displays the data source hierarchy after you connect a report to data.

RS_FieldList_DataFields

The created data source is assigned to the report’s Data Source property.

RS_ReportDataSourceAndDataMember