stored procedure with multiple SELECT and report services
I have a big trouble with report services. I need to use a stored procedure with 2 parameters (2 id). If 1st parameter is filled then a SELECT is launched. If 2nd parameter is filled then another SELE开发者_C百科CT is launched.
CREATE Procedure apGetEvrPourRapport
@id_exu int, @id_exd int
AS
BEGIN
IF isnull(@id_exu, 0) > 0
print 'id_exu : ' + cast(@id_exu as nvarchar(16))
BEGIN
EXEC apReport_Extrait_Lecture_Filtre @id_exu, null
END
-- Cas du document unique et document de travail
IF isnull(@id_exd, 0) > 0
print 'id_exd : ' + cast(@id_exd as nvarchar(16))
BEGIN
--EXEC another sp
END
END
In Data of Report Services, I retrieve the good SELECT when I filled the correct parameter in execution by the exclamation mark, but in Dataset View, I retrieve only the 2nd SELECT and so the preview fail :(
How to set Dataset to take in consideration this switch of SELECT ?
Thank you for helping.
I did exactly this about a month ago.
What you have to do is manually add the fields to the XML withing the "Fields" node of the "Dataset" node of the report, then call your stored procedure with all of its parameters. You will want to hide any columns that will not get a value in a specific scenario or they will show "#ERROR".
<Field Name="status">
<DataField>status</DataField>
<rd:TypeName>System.Byte</rd:TypeName>
</Field>
<Field Name="longname">
<DataField>longname</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="name">
<DataField>name</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
You will not be able to modify your dataset in the designer again or it will wipe out your fields and/or not save. You can still modify the other parts of your report in the designer, however.
精彩评论