I use a Parameter in the SP to pull multiple Result sets in SSRS all the time.
You have to separate them by IF statements in the SP and also you then have to HAND TYPE out the FIELDS in the SSRS Dataset setup.
Seems whacky, but it works...
Here is a example.
Stored Procedure(SP) has 2 Parameters defined
@OfficerID
@DatasetFlag
The @OfficerID is the Employee # that has to be passeed or ENTERED IN (SSRS Data input form)
The DatasetFlag is the way I control which IF statement is executed in the SP.
so here is the SP:
CREATE PROCEDURE [dbo].[StoredProcedureNameHere]
@OfficerID VARCHAR(7),
@DatasetFlag VARCHAR(60)
WITH RECOMPILE
AS
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SET NOCOUNT ON;
BEGIN TRY
IF @DatasetFlag = 'EmployeeName'
Begin
SELECT [EmployeeName]
FROM [DatabaseName].[scema].[Employee]
where EmployeeBNumber = @OfficerID
END
ELSE
IF @DatasetFlag = 'Expect'
Begin
SELECT
[TerritoryName]
,[TestNumber]
,[RuleNumber]
,[Expectation]
,[TestCount]
,[PercentToGoal]
FROM [Database].[scema].[Table2]
WHERE OfficerID = @OfficerID
ORDER BY TerritoryID
,TestNumber
,RuleNumber
END
RETURN
GO
The REPORT has 2 Datasets, one I create and it will pull in the parameters and EmployeeName
the other I create and it pulls in EmployeeName as SSRS can only use 1 Result SET~!
BUT.... I fool it ....
but I simpley CREATE the FIELDS by OVERTYPING the EMPLOYENAME and then ADD the
rest (Query) So Edit the FIELDS in the PROPERTIES of the DATASET and put in the Select Column Names.
Then I ese the PARAMETERS menu (Dataset Properties) to put in an EXPRESSION of ="EmployeeName"
for the first Dataset and ="Expect" for the 2nd. I match up the @OfficeID on that screen too.
then when I run this... it asks for OfficerID (RS creates the input form)
and when I put in the ID and hit VIEW REPORT. Or we can all the RDL with the OfficerID, just like the SSRS form does, but in an ASPX page.
BOTH DATASETS are returned (it calls it twice is my assumption)
So NO whacky FILTERING on a UNION dataset or other tricks that I have to then deal with in SSRS, which is not fun... (seriously IIF?)
I have see one Stored Procedure where we have like 20 Parameters , so you can filter
the OUTPUT of the report at the SQL level, rather than a monster pull and filter at the report.
No can you simply create 20 Stored Procedures, WELL YES, but this way, all the code is in ONE locations, and of course it can use selects into TEMP Tables to merge tons of stuff,
and in the end simply POPULATE a table that is the RESULT SET..
As a programmer I find SSRS a bit whacky, but so far I am having fun, trying to find ways to get what I want, not what it offers...