Quantcast
Channel: SQLServerCentral » Reporting Services » Reporting Services » Latest topics
Viewing all articles
Browse latest Browse all 2791

Error while creating a SSRS reports with 3 parameters and 2 datasets

$
0
0
Hi I'm trying to create a SSRS Report with 2 datasets sharing the same 3 parameters.Parameter 1 : @DataSetNameParameter 2 : @BatchStartTimeParameter 3 : @BatchEndTimeDataset 1: [code="sql"]IF @DataSetname = 'Velocity_RMCA'SELECT datasetname, BatchNumber, BatchStartTime,BatchEndTime, Runtime from Operations..DatasetSLASummary nolockwhere datasetname = 'Velocity_RMCA'and BatchStartTime >= @BatchStartTimeand BatchEndTime <= @BatchEndTimeorder by BatchStartTime descIF @DataSetname = 'Aggregation APAC01'SELECT datasetname, BatchNumber, BatchStartTime,BatchEndTime, Runtime from Operations..DatasetSLASummary nolockwhere datasetname = 'Aggregation APAC01'and BatchStartTime >= @BatchStartTimeand BatchEndTime <= @BatchEndTimeorder by BatchStartTime descIF @DataSetname = 'Aggregation APAC02'SELECT datasetname, BatchNumber, BatchStartTime,BatchEndTime, Runtime from Operations..DatasetSLASummary nolockwhere datasetname = 'Aggregation APAC02'and BatchStartTime >= @BatchStartTimeand BatchEndTime <= @BatchEndTimeorder by BatchStartTime desc[/code]Dataset 2: [code="sql"]--For Velocity_RMCAIf @DataSetName = 'Velocity_RMCA'BEGINIF OBJECT_ID('TEMPDB..#Velocity_RMCA')IS NOT NULLDROP TABLE #Velocity_RMCACREATE TABLE #Velocity_RMCA([Status] Varchar(20),Counts Float)Insert INTO #Velocity_RMCASELECT 'Total Count' as [Status], COUNT(1) from Operations..DatasetSLASummary nolockwhere datasetname in ('Velocity_RMCA')and BatchStartTime >= @BatchStartTimeand BatchEndTime <= @BatchEndTimeUnion allSelect 'Success Count' as [Status],COUNT(1) from Operations..DatasetSLASummary nolockwhere datasetname in ('Velocity_RMCA')and BatchStartTime >= @BatchStartTime and BatchEndTime <= @BatchEndTimeand cast((datediff (ss,BatchStartTime,BatchEndTime)) as decimal(8,0))/60.0 < 120Union AllSelect 'Failure Count' as [Status],COUNT(1) from Operations..DatasetSLASummary nolockwhere datasetname in ('Velocity_RMCA')and BatchStartTime >= @BatchStartTime and BatchEndTime <= @BatchEndTimeand cast((datediff (ss,BatchStartTime,BatchEndTime)) as decimal(8,0))/60.0 > 120Select * from #Velocity_RMCAUnion AllSelect 'Success Percentage' as [Status],100 - (Cast(((Select counts from #Velocity_RMCA where Status = 'Failure Count')/(Select counts from #Velocity_RMCA where Status = 'Total Count')) as decimal(10,2))* 100)ENDIf @DataSetName = 'Aggregation APAC01'BEGINIF OBJECT_ID('TEMPDB..#Aggregation_APAC01')IS NOT NULLDROP TABLE #Aggregation_APAC01CREATE TABLE #Aggregation_APAC01 ([Status] Varchar(20),Counts Float)Insert INTO #Aggregation_APAC01SELECT 'Total Count' as [Status], COUNT(1) from Operations..DatasetSLASummary nolockwhere datasetname in ('Aggregation APAC01')and BatchStartTime >= @BatchStartTimeand BatchEndTime <= @BatchEndTimeUnion allSelect 'Success Count' as [Status],COUNT(1) from Operations..DatasetSLASummary nolockwhere datasetname in ('Aggregation APAC01')and BatchStartTime >= @BatchStartTime and BatchEndTime <= @BatchEndTimeand cast((datediff (ss,BatchStartTime,BatchEndTime)) as decimal(8,0))/60.0 < 120Union AllSelect 'Failure Count' as [Status],COUNT(1) from Operations..DatasetSLASummary nolockwhere datasetname in ('Aggregation APAC01')and BatchStartTime >= @BatchStartTime and BatchEndTime <= @BatchEndTimeand cast((datediff (ss,BatchStartTime,BatchEndTime)) as decimal(8,0))/60.0 > 120Select * from #Aggregation_APAC01Union AllSelect 'Success Percentage' as [Status],100 - (Cast(((Select counts from #Aggregation_APAC01 where Status = 'Failure Count')/(Select counts from #Aggregation_APAC01 where Status = 'Total Count')) as decimal(10,2))* 100)ENDIf @DataSetName = 'Aggregation APAC02'BEGINIF OBJECT_ID('TEMPDB..#Aggregation_APAC02')IS NOT NULLDROP TABLE #Aggregation_APAC02CREATE TABLE #Aggregation_APAC02 ([Status] Varchar(20),Counts Float)Insert INTO #Aggregation_APAC02SELECT 'Total Count' as [Status], COUNT(1) from Operations..DatasetSLASummary nolockwhere datasetname in ('Aggregation APAC02')and BatchStartTime >= @BatchStartTimeand BatchEndTime <= @BatchEndTimeUnion allSelect 'Success Count' as [Status],COUNT(1) from Operations..DatasetSLASummary nolockwhere datasetname in ('Aggregation APAC02')and BatchStartTime >= @BatchStartTime and BatchEndTime <= @BatchEndTimeand cast((datediff (ss,BatchStartTime,BatchEndTime)) as decimal(8,0))/60.0 < 120Union AllSelect 'Failure Count' as [Status],COUNT(1) from Operations..DatasetSLASummary nolockwhere datasetname in ('Aggregation APAC02')and BatchStartTime >= @BatchStartTime and BatchEndTime <= @BatchEndTimeand cast((datediff (ss,BatchStartTime,BatchEndTime)) as decimal(8,0))/60.0 > 120Select * from #Aggregation_APAC02Union AllSelect 'Success Percentage' as [Status],100 - (Cast(((Select counts from #Aggregation_APAC02 where Status = 'Failure Count')/(Select counts from #Aggregation_APAC02 where Status = 'Total Count')) as decimal(10,2))* 100)END[/code]The First Dataset works perfectly fine and the data coming in the report also is accurate.Dataset 2 is not populating any data. All I get is Status and Count columns as default value in the the records.I'm not sure what I'm missing in the SQL Query. Can anyone please find out the issue.

Viewing all articles
Browse latest Browse all 2791

Trending Articles