ssrs
  1. ssrs-data-sources-and-datasets

Data Sources and Datasets

Data sources and datasets are fundamental building blocks of SSRS (SQL Server Reporting Services) reports. A data source is a connection to a database or other data source, and a dataset is a query that retrieves data from a data source.

Data Sources

A data source in SSRS is a connection to a data source that provides data for the report. A data source can be a SQL Server database, an Oracle database, an Excel file, or any other ODBC-compliant data source.

To create a new data source in SSRS, follow these steps:

  1. Open the report project in Visual Studio.
  2. In the Solution Explorer, right-click the Shared Data Sources folder and select "Add New Data Source".
  3. Follow the prompts in the wizard to specify the connection string and other details for the data source.

Once the data source is created, it can be reused in multiple reports.

Datasets

A dataset in SSRS is a query that retrieves data from the data source. A dataset can be created manually by entering a SQL query, or it can be created using the dataset wizard in SSRS.

To create a new dataset in SSRS, follow these steps:

  1. Open the report project in Visual Studio.
  2. Open the report in design view.
  3. In the Report Data pane, click "New Dataset".
  4. Follow the prompts in the wizard to specify the data source and SQL query for the dataset.

Once the dataset is created, it can be used to populate a report table or chart.

Example

Consider the following SQL query:

SELECT ProductCategory, SUM(Sales), AVG(Sales)
FROM SalesTable
GROUP BY ProductCategory

To create a dataset in SSRS that retrieves data using this query, follow these steps:

  1. Open the report project in Visual Studio.
  2. Open the report in design view.
  3. In the Report Data pane, click "New Dataset".
  4. In the dataset wizard, select the data source and enter the SQL query.
  5. In the next step, specify the parameters for the query.
  6. In the final step, preview the data for the dataset.

Once the dataset is created, it can be used to populate a report table or chart, like a bar chart that shows the total sales and average sales per product category.

Explanation

Data sources and datasets are essential building blocks of SSRS reports. A data source is a connection to a database or other data source, while a dataset is a query that retrieves data from a data source. By creating a data source and dataset in SSRS, you can retrieve and display customized data in a report.

Use

Data sources and datasets are used in SSRS reporting to retrieve and display customized data in a report. By creating a data source and dataset, you can connect to a database or other data source, run a query against it, and then display the results in a report.

Important Points

  • A data source in SSRS is a connection to a database or other data source.
  • A dataset in SSRS is a query that retrieves data from a data source.
  • Both data sources and datasets can be reused in multiple reports.
  • Datasets in SSRS can be created manually or using the dataset wizard.

Summary

Data sources and datasets are essential building blocks of SSRS reports. A data source is a connection to a database or other data source, while a dataset is a query that retrieves data from a data source. By creating a data source and dataset in SSRS, you can retrieve and display customized data in a report. Both data sources and datasets can be reused in multiple reports, and datasets can be created manually or using the dataset wizard.

Published on: