Monday 10 November 2014

SSRS - Alternate Change Column Background Color of Matrix/Table

Query:

select 1 Month,'JAN' Month_Name 
union all
select 2 ,'FEB'
union all
select 3 ,'MAR'
union all
select 4 ,'APR'
union all
select 5 ,'JUN'
union all
select 6 ,'JUL'
union all
select 7 ,'AUG'

Create a dataset using this query.
add your local datasource for this dataset.

Create Matrix as shown below and select column and follow the steps.

Step 1:


Step 2:


Step 3:

Output:




Execute SSRS Report Subscriptions Manually using SQL Query

-->Please change DateTime of LastRunTime field from below Query
-->select LastRunTime from [dbo].[Subscriptions] order by LastRunTime


-->in below Query update LastRunTime 
-->LastRunTime between '2014-11-09 07:00:04.607' and '2014-11-09 09:35:08.460'

select * into #TempR from
(select ROW_NUMBER()Over(order by j.name)ID,  cast(j.name as varchar(40)) Step 
from msdb.dbo.sysjobs j  
join  msdb.dbo.sysjobsteps js on js.job_id = j.job_id 
join ReportSchedule A on js.command like '%' + cast(A.subscriptionid as varchar(40)) + '%'


-->This join return the report id from LastRunTime date
left join
(select ItemID from [dbo].[Catalog]
where ItemID in (
select Report_OID from [dbo].[Subscriptions]
where LastRunTime between '2014-11-09 07:00:04.607' and '2014-11-09 09:35:08.460'
))P
on A.ReportID=P.ItemID
where ItemID is not null)P

declare @min int,@max int
set @min=(select Min(ID) from #TempR)
set @max=(select Max(ID) from #TempR)

select * from #TempR

--drop table #TempR

while(@min<=@max)
begin

declare @var nvarchar(max)
set @var=(select Step from #TempR where ID=@min)
execute msdb.dbo.sp_start_job @var
print @var

set @min=@min+1

end


Friday 7 November 2014

SSRS - Cascade Parameter using Dataset

--Add Dataset to SSRS Report Builder
--1.DataSet (Warehouse)
select * into #TempR from
(select '1' Warehouse
union all
select '2'
union all
select 'AB')P

select * from #TempR

drop table #TempR

--2.DataSet (Item and Price)
select * into #TempR from
(select '1' Warehouse, 'Widget'Item, '$1' Price
union all
select '1', 'Pens', '$2'
union all
select '1', 'Cards', '$5'
union all
select '2', 'Popcorn', '$2'
union all
select '2', 'Boxes', '$10'
union all
select 'AB', 'Ruler', '$10'
union all
select 'AB', 'Stapler', '$12')P

select * from #TempR
where Warehouse=@WareHouse


--Add WareHouse Parameter in Report

1.Create Parameter Name with 'WareHouse'.
2.Go to 'Available Value' in Parameter Property.
3.Go to Get Value from Query.
4.Select Dataset and Value



--Select svailable value from Dataset




--Add ItemandPrice Parameter in Report and select available value

Follow Same Steps.




--Take Textbox 
1.Right Click on Textbox
2.Goto Expression
3.Paste =Cstr(Parameters!Item.Value)+" Price :"+First(Fields!Price.Value, "ItemANDPrice")




Output:
Select Parameter



SSRS - Execute SSRS Failed Job using SQL Server

select * into #TempR from
(select ROW_NUMBER()Over(order by j.name)ID,  cast(j.name as varchar(40)) Step 
from msdb.dbo.sysjobs j  
join  msdb.dbo.sysjobsteps js on js.job_id = j.job_id 
join  [ReportServer].[dbo].[Subscriptions] s  on js.command like '%' + cast(s.subscriptionid as varchar(40)) + '%' 
where s.LastStatus like 'Failure sending mail%')P

declare @min int,@max int
set @min=(select Min(ID) from #TempR)
set @max=(select Max(ID) from #TempR)

--View Jobs List
select * from #TempR

--Execute All Jobs
while(@min<=@max)
begin

declare @var nvarchar(max)
set @var=(select Step from #TempR where ID=@min)
execute msdb.dbo.sp_start_job @var
print @var

set @min=@min+1
end

drop table #TempR