• Increase font size
  • Default font size
  • Decrease font size
Home Reporting Services SSRS Best Practice I - Limit datasets

SSRS Best Practice I - Limit datasets

E-mail Print
(0 votes)

presentation_1_cancel_128 In SQL Server Reporting Services lets you create data sets. One of the best practices for these data sets to minimize, preferably one for yourself. Once anyone ever need to change the report he does not have many data sets to search through everything, but he may provide a dataset.

Often you will be a report using parameters. Many people will have a separate dataset for each parameter. This is not necessary. With a simple trick you can because a dataset dynamic. Suppose you have a report with the Internet Sales in the AdventureWorks database. It lets the user make a choice: 'Customer' and 'Country'. If the user did not choose to see everything he gets. If a customer chooses, he must show only the customers he has chosen. If he chooses a country, the report only show the data of that country. The question now is how easy it can dissolve in a Query.

The example below shows how you can solve in your dataset. No complicated things in the report but the source address;

  AdventureWorksDW USE AdventureWorksDW
 GO

 @GeselecteerdeKlantID AS INT DECLARE @ GeselecteerdeKlantID AS INT
 @GeselecteerdeLandID AS INT DECLARE @ GeselecteerdeLandID AS INT

 @GeselecteerdeKlantID = 0 SET @ GeselecteerdeKlantID = 0
 @GeselecteerdeLandID = 2 SET @ GeselecteerdeLandID = 2

  DC. CustomerKey , SELECT DC. CustomerKey,
  , DC. FirstName,
  , DG. GeographyKey,
  , DG. English Country Name Region,
  ( FIS. SalesAmount ) AS SalesAmount SUM (Amount FIS. Sales) AS Sales Amount
    FactInternetSales AS FIS FROM Fact Internet Sales AS FIS
  DimCustomer AS DC ON FIS. CustomerKey = DC. CustomerKey LEFT OUTER JOIN AS DimCustomer DC ON FIS. CustomerKey = DC. CustomerKey
  DimGeography AS DG ON DC. GeographyKey = DG. GeographyKey LEFT OUTER JOIN AS DimGeography DG ON DC. GeographyKey = DG. GeographyKey
 ( WHERE (
  @GeselecteerdeKlantID, 0 ) = 0 ISNULL (@ GeselecteerdeKlantID, 0) = 0
  = @GeselecteerdeKlantID ) OR DC. CustomerKey = @ GeselecteerdeKlantID)
  AND (
  @GeselecteerdeLandID, 0 ) = 0 ISNULL (@ GeselecteerdeLandID, 0) = 0
  = @GeselecteerdeLandID ) OR DG. GeographyKey = @ GeselecteerdeLandID)
 DC. CustomerKey , GROUP BY DC. CustomerKey,
  , DC. FirstName,
  , DG. GeographyKey,
  General. English Country Region Name 

Copyright 2008. All Rights Reserved.

Trackback (0)

TrackBack URI for this post

Comment (0)

RSS feed Comments

Write comment

bold italicize underline strike url image quote smile wink laugh grin angry sad shocked cool tongue kiss cry
| groter smaller | bigger
security image
Write the displayed characters

busy