Thursday, April 14, 2011

Run SP's or Select Queries by SQLCMD

SQLCMD command utility requires a sql script file with sql statements or Stored Procedures.SQLCMD will invoke SQL file in command prompt and run the scripts inside the *.SQL file as run normally by using SQL Server management Studio.
-- Go to Command Prompt
-- Go to C drive C:\>
-- Type the following command inorder to run SQL script
FileName.sql --> Contains either select statement or set of stored procedures
-- From local systemsqlcmd -S -i \\ServerName\Foldername\FileName.sql-- Running On Serversqlcmd -S -i C:\FileName.sql

Execute StoredProcedure By Using SQLCMD

The following example shows how to execute a stored procedure by using sqlcmd

IF OBJECT_ID ( ' dbo.ContactEmailAddress, 'P' ) IS NOT NULL
DROP PROCEDURE dbo.ContactEmailAddress;
GO
USE AdventureWorks2008
CREATE PROCEDURE dbo.ContactEmailAddress
(
@FirstName nvarchar(50)
,@LastName nvarchar(50)
)
AS
SET NOCOUNT ON
SELECT EmailAddress
FROM Person.Person
WHERE FirstName = @FirstName
AND LastName = @LastName;
SET NOCOUNT OFF
At the sqlcmd prompt, enter the following:
C:\sqlcmd
1> :Setvar FirstName Gustavo
1> :Setvar LastName Achong
1> EXEC dbo.ContactEmailAddress $(Gustavo),$(Achong)
2> GO
EmailAddress
-----------------------------
gustavo0@adventure-works.com

Tuesday, April 12, 2011

DATE Dimension

Hi All,
During last couple of days I was working on how to create a stored procedure in order to populate data into Dimensions Date table. In Stored procedure,used some variables which are not using while inserting into Dimensions.Date table.This stored procedure also handles local language translations for Denmark,Sweden,Finnish,Norway and UK or US countries.
-- Dimensions.Date table structure

CREATE TABLE [Dimensions].[Date](
[Datekey] [int] NOT NULL,
[Date] [date] NULL,
[DateText] [char](10) NULL,
[DateTextDA] [char](20) NULL,
[DateTextEN] [char](20) NULL,
[DateTextSE] [char](20) NULL,
[DateTextNO] [char](20) NULL,
[DateTextFI] [char](20) NULL,
[YearKey] [smallint] NULL,
[Year] [date] NULL,
[HalfYearOfYearKey] [tinyint] NULL,
[HalfYear] [date] NULL,
[HalfYearText] [char](5) NULL,
[HalfYearTextDA] [char](20) NULL,
[HalfYearTextEN] [char](20) NULL,
[HalfYearTextSE] [char](20) NULL,
[HalfYearTextNO] [char](20) NULL,
[HalfYearTextFI] [char](20) NULL,
[QuarterOfYearKey] [tinyint] NULL,
[Quarter] [date] NULL,
[QuarterText] [char](5) NULL,
[QuarterTextDA] [char](20) NULL,
[QuarterTextEN] [char](20) NULL,
[QuarterTextSE] [char](20) NULL,
[QuarterTextNO] [char](20) NULL,
[QuarterTextFI] [char](15) NULL,
[MonthOfYearKey] [smallint] NULL,
[Month] [date] NULL,
[MonthText] [char](5) NULL,
[MonthTextDA] [char](14) NULL,
[MonthTextEN] [char](14) NULL,
[MonthTextSE] [char](14) NULL,
[MonthTextNO] [char](14) NULL,
[MonthTextFI] [char](14) NULL,
[ISOWeek] [int] NULL,
[USWeek] [int] NULL,
[ISOWeekKey] [tinyint] NULL,
[USWeekKey] [tinyint] NULL,
[DaysInYear] [smallint] NULL,
[DaysInYearToDate] [smallint] NULL,
[DaysInHalfYear] [smallint] NULL,
[DaysInHalfYearToDate] [smallint] NULL,
[DaysInQuarter] [smallint] NULL,
[DaysInQuarterToDate] [smallint] NULL,
[DaysInMonth] [smallint] NULL,
[DaysInMonthToDate] [smallint] NULL
)

-- Stored Procedure to populate data

CREATE PROCEDURE [dbo].[uspPopulatesDimensionsDate]
-- Add the parameters for the stored procedure here
@p_start_year date,
    @p_end_year date
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
Declare @date datetime -- DateTime
Declare @date_end datetime -- DateTime
Declare @calendar_date_id integer
Declare @date_short_name varchar(25)
Declare @date_long_name varchar(50)
Declare @day_in_week smallint
Declare @day_in_month smallint
Declare @day_in_qtr smallint
Declare @day_in_year smallint
Declare @day_of_week_abbr nvarchar(3)
Declare @week_in_year integer
Declare @week_id integer
Declare @padded_week_in_year nvarchar(2)
Declare @year integer
Declare @week_start_date date
Declare @week_end_date datetime
Declare @week_short_name varchar(25)
Declare @week_long_name varchar(50)
Declare @week_in_month smallint
Declare @week_in_qtr smallint
Declare @month_short_name nvarchar(25)
Declare @month_long_name nvarchar(50)
Declare @month_start_date datetime
Declare @half_span smallint
Declare @br_month_start_date datetime
Declare @month_end_date datetime
Declare @month_id integer
Declare @padded_month_in_year nvarchar(2)
Declare @padded_qtr_in_year nvarchar(2)
Declare @month_in_year smallint
Declare @qtr_in_year smallint
Declare @month_in_qtr smallint
Declare @month_span smallint
Declare @qtr_id integer
Declare @qtr_short_name varchar(25)
Declare @qtr_long_name varchar(50)
Declare @qtr_start_date datetime
Declare @qtr_end_date datetime
Declare @qtr_span smallint
Declare @year_short_name varchar(25)
Declare @year_long_name varchar(50)
Declare @year_start_date datetime
Declare @year_end_date datetime
Declare @year_span smallint
Declare @padded_day_in_month char(2)
Declare @date_id integer
Declare @DateTextDA char (20)
Declare @DateTextEN char (20)
Declare @DateTextSE char (20)
Declare @DateTextNO char (20)
Declare @DateTextFI char (20)
Declare @HalfyearText char (5)
Declare @HalfYearOfYearKey tinyint
Declare @HalfYear date
Declare @HalfYearStartDate Date
Declare @HalfYearEndDate Date
Declare @HalfYearSpan TinyInt
Declare @DaysInHalfYear TinyInt
Declare @QuarterOfyearKey TinyInt
Declare @Quarter Datetime
Declare @QuarterText char (5)
Declare @MonthTextDA Char(14)
Declare @MonthTextEN Char(14)
Declare @MonthTextSE Char(14)
Declare @MonthTextNO Char(14)
Declare @MonthTextFI Char(14)
declare @cntr int


set @date = cast(0 as datetime)
set @date = @p_start_year


-- Truncate table Dimensions.Date data before inserting data
Truncate table Dimensions.Date


while @date <= @p_end_year
begin
/* Define standard calendar */
set @date_end = dateadd(ss, -1, dateadd(d, 1, @date))
set @day_in_week = datepart(dw, @date)
set @day_in_month = datepart(d, @date)
set @padded_day_in_month = right('00' + rtrim(cast(@day_in_month as char(2))), 2)
set @qtr_start_date = dateadd(q, datediff(q, 0, @date), 0)
set @day_in_qtr = datediff(d, @qtr_start_date, @date) + 1
set @day_in_year = datepart(dy, @date)
set @day_of_week_abbr = left(datename(dw, @date), 3)
set @week_in_year = datepart(wk, @date)
set @padded_week_in_year = right('00' + rtrim(cast(@week_in_year as char(2))), 2)
set @year = datepart(yy, @date)
set @week_start_date = dateadd(d, 1- @day_in_week, @date)
--set @week_end_date = dateadd(ss, -1, dateadd(wk, 1, @week_start_date))
set @week_end_date = dateadd(DD, -1, dateadd(wk, 1, @week_start_date))
set @week_short_name =  @padded_week_in_year + '-' +  cast(@year as char(4))
set @week_long_name =  @padded_week_in_year + ', ' + cast(@year as char(4))
   set @week_in_qtr = 
         CASE
              WHEN datepart(mm, @date) >=1 and datepart(mm, @date) <=3 THEN 
                   datediff(wk, cast('01/01/' + cast(datepart(yyyy, @date) as nvarchar(4)) as smalldatetime), @date) + 1
              WHEN datepart(mm, @date) >=4 and datepart(mm, @date)<=6 THEN
                datediff(wk, cast('04/01/' + cast(datepart(yyyy,@date) as nvarchar(4)) as smalldatetime),@date) + 1
             WHEN datepart(mm, @date)>=7 and datepart(mm, @date)<= 9 THEN
                     datediff(wk, cast('07/01/' + cast(datepart(yyyy,@date) as nvarchar(4)) as smalldatetime),@date) + 1
                ELSE
                     datediff(wk, cast('10/01/' + cast(datepart(yyyy,@date) as nvarchar(4)) as smalldatetime),@date) + 1
          END 


   set @week_in_month =
           CASE
             WHEN datepart(mm, @date) = 1  THEN 
                  datediff(wk, cast('01/01/' + cast(datepart(yyyy, @date) as nvarchar(4)) as smalldatetime), @date) + 1
                 WHEN datepart(mm, @date) = 2  THEN 
                   datediff(wk, cast('02/01/' + cast(datepart(yyyy, @date) as nvarchar(4)) as smalldatetime), @date) + 1
                 WHEN datepart(mm, @date) = 3  THEN 
                   datediff(wk, cast('03/01/' + cast(datepart(yyyy, @date) as nvarchar(4)) as smalldatetime), @date) + 1
                 WHEN datepart(mm, @date) = 4 THEN
                   datediff(wk, cast('04/01/' + cast(datepart(yyyy,@date) as nvarchar(4)) as smalldatetime),@date) + 1
                 WHEN datepart(mm, @date) = 5 THEN
                   datediff(wk, cast('05/01/' + cast(datepart(yyyy,@date) as nvarchar(4)) as smalldatetime),@date) + 1
                 WHEN datepart(mm, @date) = 6 THEN
                   datediff(wk, cast('06/01/' + cast(datepart(yyyy,@date) as nvarchar(4)) as smalldatetime),@date) + 1
                 WHEN datepart(mm, @date) = 7 THEN
                    datediff(wk, cast('07/01/' + cast(datepart(yyyy,@date) as nvarchar(4)) as smalldatetime),@date) + 1
                 WHEN datepart(mm, @date) = 8 THEN
                   datediff(wk, cast('08/01/' + cast(datepart(yyyy,@date) as nvarchar(4)) as smalldatetime),@date) + 1
                 WHEN datepart(mm, @date) = 9 THEN
                   datediff(wk, cast('09/01/' + cast(datepart(yyyy,@date) as nvarchar(4)) as smalldatetime),@date) + 1
                 WHEN datepart(mm, @date) = 10 THEN
                   datediff(wk, cast('10/01/' + cast(datepart(yyyy,@date) as nvarchar(4)) as smalldatetime),@date) + 1
                 WHEN datepart(mm, @date) = 11 THEN
                   datediff(wk, cast('11/01/' + cast(datepart(yyyy,@date) as nvarchar(4)) as smalldatetime),@date) + 1
                 WHEN datepart(mm, @date) = 12 THEN
                    datediff(wk, cast('12/01/' + cast(datepart(yyyy,@date) as nvarchar(4)) as smalldatetime),@date) + 1
                 ELSE
                      0
              END 


if left(datepart(MONTH, @date), 3) < 10
set @month_short_name = '0'+ left(datepart(MONTH, @date), 3) + '-' + cast(@year as char(4))
Else 
Set @month_short_name = left(datepart(MONTH, @date), 3) + '-' + cast(@year as char(4))
set @month_long_name = datename(m, @date) + ' ' + cast(@year as char(4))
set @month_start_date = dateadd(m, datediff(m, 0, @date), 0)
set @qtr_in_year = datepart(q, @date)
set @month_in_year = datepart(m, @date)
set @month_in_qtr = ((@month_in_year - 1) % 3) + 1
set @month_end_date = dateadd(ss, -1, dateadd(m, 1, @month_start_date))
set @month_span = datepart(d, @month_end_date)
set @padded_month_in_year = right('00' + rtrim(cast(@month_in_year as char(2))), 2)
set @week_id = cast(@year as char(4)) + @padded_week_in_year + @padded_month_in_year
set @month_id = cast(@year as char(4)) + @padded_month_in_year
       set @padded_qtr_in_year = right('00' + rtrim(cast(@qtr_in_year as char(2))), 2)
set @qtr_id = cast(@year as char (4)) + @padded_qtr_in_year

set @qtr_short_name = 'Q' +cast(@qtr_in_year as char(1)) + '-' + Right(@year,2) --cast(@year as char(4))

set @qtr_long_name =
case @qtr_in_year
when 1 then '1st'
when 2 then '2nd'
when 3 then '3rd'
when 4 then '4th'
end
+ ' Quarter, ' + cast(@year as char(4))

Set @QuarterText = @qtr_short_name
Set @QuarterOfyearKey = Case 
when  left(@QuarterText,2) = 'Q1' then 1
when  left(@QuarterText,2) = 'Q2' then 2
when  left(@QuarterText,2) = 'Q3' then 3
when  left(@QuarterText,2) = 'Q4' then 4
END 

set @qtr_end_date = dateadd(ss, -1, dateadd(q, 1, @qtr_start_date))
set @qtr_span = datediff(d, @qtr_start_date, @qtr_end_date) + 1
set @year_short_name = @year
set @year_long_name = 'Year - ' + cast(@year as char(4))
set @year_start_date = dateadd(yy, datediff(yy, 0, @date), 0)
set @year_end_date = dateadd(DD, -1, dateadd(yy, 1, @year_start_date))
set @year_span = datediff(d, @year_start_date, @year_end_date) + 1
set @date_id = cast(@year as char(4)) + @padded_month_in_year + @padded_day_in_month
set @date_short_name = @padded_day_in_month + '-' + @month_short_name
set @date_long_name = datename(mm, @date) + ' ' + cast(@day_in_month as varchar(2)) + ', ' +          cast(@year as char(4))
set @HalfYearOfYearKey = Case when left(@month_short_name,2) < '07' then 1 else 2 End
SET @HalfYearStartDate = 
CASE WHEN @HalfYearOfYearKey = 1 THEN @year_start_date ELSE DATEADD(M,6,@year_start_date) END
SET @HalfYearEndDate = DATEADD(d,-1,dateadd(m,6,@HalfYearStartDate))
SET @HalfYearSpan = Datediff(D,@HalfYearStartDate,@HalfYearEndDate) +1
SET @DaysInHalfYear = Datediff(D,@HalfYearStartDate,@date) +1
Set @HalfYear = Case when left(@month_short_name,2) < '07' then LEFT(@year,4)+ '-01-01' else  LEFT(@year,4)+ '-07-01' End
Set @HalfyearText = Case when left(@month_short_name,2)  < '07' then '1H-' +right(@year,2) else '2H-' + right(@year,2) End
SET LANGUAGE Danish
SELECT @DateTextDA = DATEname(DAY,@date) + '. ' + DATENAME(month, @date) + ' ' + Datename(YEAR, @date)
SELECT @MonthTextDA =  DATENAME(month, @date) + '-' + right(@year,2)
SET LANGUAGE British
SELECT @DatetextEN = DATEname(DAY,@date) + '  ' + DATENAME(month, @date) + ' ' + Datename(YEAR, @date)
SELECT @MonthtextEN = DATENAME(month, @date) + '-' +right(@year,2)
SET LANGUAGE Swedish
SELECT @DateTextSE = DATEname(DAY,@date) + '. ' + DATENAME(month, @date) + ' ' + Datename(YEAR, @date)
SELECT @MonthTextSE = DATENAME(month, @date) + '-' + right(@year,2)
SET LANGUAGE Norwegian
Set @DateTextNO = DATEname(DAY,@date) + '. ' + DATENAME(month, @date) + ' ' + Datename(YEAR, @date)
Set @MonthTextNO =  DATENAME(month, @date) + '-' + right(@year,2)
SET LANGUAGE Finnish
Set @DateTextFI = DATEname(DAY,@date) + '. ' + DATENAME(month, @date) + ' ' + Datename(YEAR, @date)
Set @MonthTextFI = DATENAME(month, @date) + '-' +right(@year,2)

Set language English
Insert into Dimensions.Date
Select 
@Date_id as DateKey,
@date as Date,
left(@date_short_name,2)+'-'+@month_short_name AS DateText,
--@day_in_week,
--@day_of_week_abbr,
@DateTextDA as DateTextDA,
@DateTextEN as DateTextEN,
@DateTextSE as DateTextSE,
@DateTextNO as DateTextNO,
@DateTextFI as DateTextFI,
@year as YearKey,
@Date as Year,
@HalfYearOfYearKey,
@HalfYear,
@HalfyearText,
HalfyearTextDA =  case
when left(@HalfyearText,2) = '1H' then '1. Halvår' + '-' + right(@year,2)
when left(@HalfyearText,2) = '2H' then '2. Halvår' + '-' + right(@year,2)
end,
HalfyearTextEN =  case
when left(@HalfyearText,2) = '1H' then '1st Half-year' + '-' + right(@year,2)
when left(@HalfyearText,2) = '2H' then '2nd Half-year' + '-' + right(@year,2)
end,
HalfyearTextSE =  case
when left(@HalfyearText,2) = '1H' then '1. Halvår' + '-' + right(@year,2)
when left(@HalfyearText,2) = '2H' then '2. Halvår' + '-' + right(@year,2)
end,
HalfyearTextNO =  case
when left(@HalfyearText,2) = '1H' then '1. Halvår' + '-' + right(@year,2)
when left(@HalfyearText,2) = '2H' then '2. Halvår' + '-' + right(@year,2)
end,
HalfyearTextFI =  case
when left(@HalfyearText,2) = '1H' then '1. Puolen-vuoden' + '-' + right(@year,2)
when left(@HalfyearText,2) = '2H' then '2. Puolen-vuoden' + '-' + right(@year,2)
 end,
QuarterOfyearKey = Case 
when  left(@QuarterText,2) = 'Q1' then 1
when  left(@QuarterText,2) = 'Q2' then 2
when  left(@QuarterText,2) = 'Q3' then 3
when  left(@QuarterText,2) = 'Q4' then 4
END ,
Quarter = case
when left(@QuarterText,2) = 'Q1' then right(@year,4) + '0101'
when left(@QuarterText,2) = 'Q2' then right(@year,4) + '0401'
when left(@QuarterText,2) = 'Q3' then right(@year,4) + '0701'
when left(@QuarterText,2) = 'Q4' then right(@year,4) + '1001'
end,
@QuarterText,
QuarterTextDA =  case
when left(@QuarterText,2) = 'Q1' then '1. Kvartal' + '-' + right(@year,2)
when left(@QuarterText,2) = 'Q2' then '2. Kvartal' + '-' + right(@year,2)
when left(@QuarterText,2) = 'Q3' then '3. Kvartal' + '-' + right(@year,2)
when left(@QuarterText,2) = 'Q4' then '4. Kvartal' + '-' + right(@year,2)
end,
QuarterTextEN =  case
when left(@QuarterText,2) = 'Q1' then '1st Quarter' + '-' + right(@year,2)
when left(@QuarterText,2) = 'Q2' then '2nd Quarter' + '-' + right(@year,2)
when left(@QuarterText,2) = 'Q3' then '3rd Quarter' + '-' + right(@year,2)
when left(@QuarterText,2) = 'Q4' then '4th Quarter' + '-' + right(@year,2)
end,
QuarterTextSE =  case
when left(@QuarterText,2) = 'Q1' then '1. Kvartal' + '-' + right(@year,2)
when left(@QuarterText,2) = 'Q2' then '2. Kvartal' + '-' + right(@year,2)
when left(@QuarterText,2) = 'Q3' then '3. Kvartal' + '-' + right(@year,2)
when left(@QuarterText,2) = 'Q4' then '4. Kvartal' + '-' + right(@year,2)
end,
QuarterTextNO =  case
when left(@QuarterText,2) = 'Q1' then '1. Kvartal' + '-' + right(@year,2)
when left(@QuarterText,2) = 'Q2' then '2. Kvartal' + '-' + right(@year,2)
when left(@QuarterText,2) = 'Q3' then '3. Kvartal' + '-' + right(@year,2)
when left(@QuarterText,2) = 'Q4' then '4. Kvartal' + '-' + right(@year,2)
end,
QuarterTextFI =  case
when left(@QuarterText,2) = 'Q1' then '1. Neljännes' + '-' + right(@year,2)
when left(@QuarterText,2) = 'Q2' then '2. Neljännes' + '-' + right(@year,2)
when left(@QuarterText,2) = 'Q3' then '3. Neljännes' + '-' + right(@year,2)
when left(@QuarterText,2) = 'Q4' then '4. Neljännes' + '-' + right(@year,2)
End,
@month_in_year,
Month = Case 
when left(@month_short_name,2) = '01' then right(@year,4) + '-01-01'
when left(@month_short_name,2) = '02' then right(@year,4) + '-02-01'
when left(@month_short_name,2) = '03' then right(@year,4) + '-03-01'
when left(@month_short_name,2) = '04' then right(@year,4) + '-04-01'
when left(@month_short_name,2) = '05' then right(@year,4) + '-05-01'
when left(@month_short_name,2) = '06' then right(@year,4) + '-06-01'
when left(@month_short_name,2) = '07' then right(@year,4) + '-07-01'
when left(@month_short_name,2) = '08' then right(@year,4) + '-08-01'
when left(@month_short_name,2) = '09' then right(@year,4) + '-09-01'
when left(@month_short_name,2) = '10' then right(@year,4) + '-10-01'
when left(@month_short_name,2) = '11' then right(@year,4) + '-11-01'
when left(@month_short_name,2) = '12' then right(@year,4) + '-12-01'
end,
MonthText = left(@month_short_name,2)+'-'+right(@year,2),
@MonthTextDA,
@MonthTextEN,
@MonthTextSE,
@MonthTextNO,
@MonthTextFI,
ISOWeek = right(@year,4)+left(@month_short_name,2),
USWeek = right(@year,4)+left(@month_short_name,2),
ISOWeekKey = DATEPART(ISO_WEEK, @date),
USWeekKey = DATEPART(WW, @date),
@year_span as DaysInYear,
@day_in_year as DaysInYearToDate,
@HalfYearSpan,
@DaysInHalfYear,
@qtr_span as DaysInQuarter, 
@day_in_qtr as DaysInQuarterToDate,
@month_span as DaysInMonth,
@day_in_month as DaysInMonthToDate
set @date = dateadd(d, 1, @date)
end
END

Tuesday, March 22, 2011

Types of SSRS Reports

With Reporting Services, you can create the following types of reports:
·         Parameterized reports
·         Linked reports
·         Snapshot reports
·         Cached reports
·         Ad hoc reports
·         Clickthrough reports
·         Drilldown reports
·         Drillthrough reports
·         Subreports

Parameterized Report

A parameterized report uses input values to complete report or data processing. With a parameterized report, you can vary the output of a report based on values that are set when the report runs. Parameterized reports are frequently used for drillthrough reports, linked reports, and subreports, connecting and filtering reports with related data.

Using Parameters
Parameters are used in dataset queries to select report data, to filter the result set that the query returns, or to set layout properties used to display or hide parts of a report. You can also specify cascading parameters that populate a series of dependent, drop-down parameter lists. For example, a drop-down list of Region parameter values can be used to populate a drop-down list of City parameter values.
You can use parameters with linked reports by pairing a specific parameter with each linked report to change the outcome. For example, you can create a single regional sales report that shows the sales for all regions, and then use a parameter for each linked report to filter data for a particular region. Specific parameter values can be stored with the report so that users do not have to type values.
Not all parameters may be visible in the report at run time. A report author, report server administrator, or content manager can specify which values to use and then hide the input fields on the report.

Query Parameters and Report Parameters

Reporting Services supports two kinds of parameters: query parameters and report parameters. Query parameters are used during data processing to select or filter data. Query parameters are specified in the syntax of a data processing extension. If a query parameter is specified, a value must be provided either by the user or by default properties to complete the SELECT statement or stored procedure that retrieves data for a report. Report parameters are used during report processing to show a different aspect of the data. A report parameter is usually used to filter a large set of records, but it can have other uses depending on the queries and expressions used in the report. Report parameters differ from query parameters in that they are defined in a report and processed by the report server, while query parameters are defined as part of the dataset query and processed on the database server.

Linked Reports
A linked report is a report server item that provides an access point to an existing report. Conceptually, it is similar to a program shortcut that you use to run a program or open a file.
A linked report is derived from an existing report and retains the original's report definition. A linked report always inherits report layout and data source properties of the original report. All other properties and settings can be different from those of the original report, including security, parameters, location, subscriptions, and schedules.You can create a linked report on the report server when you want to create additional versions of an existing report. For example, you could use a single regional sales report to create region-specific reports for all of your sales territories.
Although linked reports are typically based on parameterized reports, a parameterized report is not required. You can create linked reports whenever you want to deploy an existing report with different settings.
Snapshot Reports
A report snapshot is a report that contains layout information and query results that were retrieved at a specific point in time. Unlike on-demand reports, which get up-to-date query results when you select the report, report snapshots are processed on a schedule and then saved to a report server. When you select a report snapshot for viewing, the report server retrieves the stored report from the report server database and shows the data and layout that were current for the report at the time the snapshot was created.
Report snapshots are not saved in a particular rendering format. Instead, report snapshots are rendered in a final viewing format (such as HTML) only when a user or an application requests it. Deferred rendering makes a snapshot portable. The report can be rendered in the correct format for the requesting device or Web browser.
Report snapshots serve three purposes:
·         Report history. By creating a series of report snapshots, you can build a history of a report that shows how data changes over time.
·         Consistency. Use report snapshots when you want to provide consistent results for multiple users who must work with identical sets of data. With volatile data, an on-demand report can produce different results from one minute to the next. A report snapshot, by contrast, allows you to make valid comparisons against other reports or analytical tools that contain data from the same point in time.
·         Performance. By scheduling large reports to run during off-peak hours, you can reduce processing impact on the report server during core business hours.

Cached Reports
A cached report is a saved copy of a processed report. Cached reports are used to improve performance by reducing the number of processing requests to the report processor and by reducing the time required to retrieve large reports. They have a mandatory expiration period, usually in minutes. 
Clickthrough Reports
A clickthrough report is a report that displays related data from a report model when you click the interactive data contained within your model-based report. These reports are generated by the report server based on the information contained within the report model. The person who created the model determines which fields are interactive and which fields are returned when a clickthrough report is opened. These field settings cannot be changed in the report authoring tools.
Clickthrough reports are autogenerated. However, you can create an alternative customized report to the model for interactive data items that is displayed instead. The custom report is a standard Reporting Services report.
Drilldown Reports
Drilldown reports initially hide complexity and enable the user to toggle conditionally hidden report items to control how much detail data they want to see. Drilldown reports must retrieve all possible data that can be shown in the report. For reports with large amounts of data, consider drillthrough reports instead.
Drillthrough Reports
Drillthrough reports are standard reports that are accessed through a hyperlink on a text box in the original report. Drillthrough reports work with a main report and are the target of a drillthrough action for a report item such as placeholder text or a chart. The main report displays summary information, for example in a matrix or chart. Actions defined in the matrix or chart provide drillthrough links to reports that display greater details based on the aggregate in the main report. Drillthrough reports can be filtered by parameters, but they do not have to be. Drillthrough reports differ from subreports in that the report does not display within the original report, but opens separately. They differ from clickthrough reports in that they are not autogenerated from the data source, but are instead custom reports that are saved on the report server. They differ from drilldown reports in that they retrieve the report data only for the specified parameters or for the dataset query.

Subreports
A subreport is a report that displays another report inside the body of a main report. Conceptually, a subreport is similar to a frame in a Web page. It is used to embed a report within a report. Any report can be used as a subreport. The subreport can use different data sources than the main report. The report that the subreport displays is stored on a report server, usually in the same folder as the parent report. You can set up the parent report to pass parameters to the subreport.
Although a subreport can be repeated within data regions using a parameter to filter data in each instance of the subreport, subreports are typically used with a main report as a briefing book or as a container for a collection of related reports. For reports with many instances of subreports, consider using drillthrough reports instead.