all groups > sql server reporting services > november 2007 >
You're in the

sql server reporting services

group:

Stored Procedure


Stored Procedure
11/2/2007 12:07:38 AM
sql server reporting services:
Is it possible to pass a field value as a parameter to a stored
procedure?

I included 2 datasets in my report. The first dataset contains the
data fields while the other retrieves a stored procedure.
I need to pass the parameter to the stored procedure based on the data
field of the first dataset without manually keying in the value.

I'm currently running the stored procedure via a subreport so that the
parameter can be passed to the stored procedure. It works but
wondering if I can directly do it so that the subreport is not needed.
Re: Stored Procedure Bruce L-C [MVP]
11/2/2007 8:16:47 AM
You are doing it the correct way (subreports). That is the only way to do
it.


--
Bruce Loehle-Conger
MVP SQL Server Reporting Services

[quoted text, click to view]

Re: Stored Procedure Alain Quesnel
11/2/2007 9:15:44 AM
Edit the properties of the datasource that uses the stored proc, go to the
parameters tab and enter the value of the field you want to pass as a
parameter (ex.: =Fields!Myfield.Value). If your 2nd dataset returns more
than one row, you might have to do something like
=First(Fields!Myfield.Value) I'm not too sure about this last one. You'd
have to test it. You can also use a parameter that is used by another
dataset (ex.: =Parameters!MyParam.Value)

--

Alain Quesnel
alainsansspam@logiquel.com

www.logiquel.com


[quoted text, click to view]
Re: Stored Procedure Bruce L-C [MVP]
11/2/2007 9:44:21 AM
As you mention you can have multiple datasets using same parameter(s). And
you can do as you say below. But, what you cannot do is a join of datasets
which is what it sounds like what he wants to do. I.e. there are several
records with a different value in MyField and the SP should be called
multiple times. This requires a subreport.

One caveat on your method below, the dataset that is dependent on the other
dataset and is using the First aggregate must physically be defined in the
RDL after the main one. RS pulls in the data in the order of the definitions
in the RDL. If for whatever reason this is not the case you need to hand
modify (carefully) the RDL.


--
Bruce Loehle-Conger
MVP SQL Server Reporting Services

[quoted text, click to view]

Re: Stored Procedure Bruce L-C [MVP]
11/2/2007 10:08:24 AM
I would think it would. The xml isn't hard to look at and move around, you
just have to be careful.


--
Bruce Loehle-Conger
MVP SQL Server Reporting Services

[quoted text, click to view]

Re: Stored Procedure Alain Quesnel
11/2/2007 10:23:30 AM
BTW, I use a stored proc (displayed in a table) as a second datasource
within a single report. The stored proc uses the same parameter that is used
by the first dataset, and everything works fine. I'm not using a subreport.

--

Alain Quesnel
alainsansspam@logiquel.com

www.logiquel.com


[quoted text, click to view]
Re: Stored Procedure Alain Quesnel
11/2/2007 10:29:42 AM
In my second example below, you might need to specify the datasource like
this:

=First(Fields!Myfield.Value, "MyDataSource")

--

Alain Quesnel
alainsansspam@logiquel.com

www.logiquel.com


[quoted text, click to view]
Re: Stored Procedure Alain Quesnel
11/2/2007 10:51:43 AM
I probably created them in chronological order, without realizing it would
make a difference.

Do you know if deleting the datasources and recreating them in the proper
order works? i.e. without having to manually modify the RDL file?

--

Alain Quesnel
alainsansspam@logiquel.com

www.logiquel.com


[quoted text, click to view]
AddThis Social Bookmark Button