all groups > sql server reporting services > august 2004 >
You're in the

sql server reporting services

group:

Stored procedure parameters and default values


Re: Stored procedure parameters and default values Bruce Loehle-Conger
8/10/2004 4:12:43 PM
sql server reporting services:
When I use a stored procedure I usually test it first by hard coding the
stored procedure parameters. Later I add the query parameter. Not sure what
the problem is that you are seeing.

Bruce L-C

"Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.com> wrote in
message news:%23QFQ6ixfEHA.1092@TK2MSFTNGP11.phx.gbl...
[quoted text, click to view]

Re: Stored procedure parameters and default values Jeff Dillon
8/10/2004 4:38:20 PM
From SQL Books online, not sure if this will help. The code below creates
default parameters for a sproc if none is supplied when called.

CREATE PROCEDURE au_info2
@lastname varchar(30) = 'D%',
@firstname varchar(18) = '%'
AS
SELECT au_lname, au_fname, title, pub_name
FROM authors a INNER JOIN titleauthor ta
ON a.au_id = ta.au_id INNER JOIN titles t
ON t.title_id = ta.title_id INNER JOIN publishers p
ON t.pub_id = p.pub_id
WHERE au_fname LIKE @firstname
AND au_lname LIKE @lastname
GO

"Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.com> wrote in
message news:uqcjBAyfEHA.3048@TK2MSFTNGP09.phx.gbl...
[quoted text, click to view]

Stored procedure parameters and default values Tibor Karaszi
8/10/2004 10:29:24 PM
Again, seeking confirmation that I'm on the right track:

Say I have a stored procedure that I want to re-use in several different reports. For some, I want to
hard-wire the parameters without modifying the procedure code. What options do I have?

Am I correct in thinking that if I use command type "stored procedure", I should *only* have the procedure
name as "command text". I.e., I cannot specify parameter values in the proc call?

And if I use command type as "query string", RD will parse the string and figure out the parameters, so the
same goes here?

If above is correct, what options do I have?
I can specify a default value in "Report", "Report Parameters", but that parameter will still be there when I
execute it from the "Preview" tab. I understand I can pass it in the URL when I deploy the report, but that
seems to be messy way for such a simple task. Any other options, am I missing the obvious?

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/


Re: Stored procedure parameters and default values Robert Bruckner [MSFT]
8/10/2004 10:52:43 PM
As you have noticed, the report designer will automatically detect "query"
parameters, generate corresponding report parameters, and link them
together. E.g. the generated RDL file would contain something similar to
this:

<Query>
<DataSourceName>DataSource1</DataSourceName>
<CommandType>StoredProcedure</CommandType>
<CommandText>get_report_viewing_frequency</CommandText>
<QueryParameters>
<QueryParameter Name="company_id">
<Value>=Parameters!company_id.Value</Value>
</QueryParameter>
</QueryParameters>
</Query>

Note: The query parameter value is an expression!
You can always modify the linking between report parameters and query
parameters (edit the dataset -> in the dataset dialog click on the
Parameters tab). You could change the query parameter value expression to a
constant value or an expression which does not depend on a report parameter.

You can even remove automatically generated report parameters (VS menu:
Report - Report Parameters).

--
This posting is provided "AS IS" with no warranties, and confers no rights.




"Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.com> wrote in
message news:eMr9mw1fEHA.3556@TK2MSFTNGP12.phx.gbl...
[quoted text, click to view]

Re: Stored procedure parameters and default values Tibor Karaszi
8/10/2004 11:21:29 PM
Hmm, perhaps I'm missing something. The environment creates one report parameter for each parameter to the
stored procedure. This is regardless of whether I hard code the proc parameter and use command type "SQL text"
instead of "stored procedure". And from there' there just don't seem to be a way to get rid of this parameter
when I execute the procedure (as the top, where RD ask for the parameter values).

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/


[quoted text, click to view]

Re: Stored procedure parameters and default values Tibor Karaszi
8/11/2004 6:32:02 AM
Not what I'm looking for, I'm afraid. IT doesn't mater whether the proc has default values for the parameters
or not. The parameters will still be visible when you run the report.

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/


[quoted text, click to view]

Re: Stored procedure parameters and default values Bruce Loehle-Conger
8/11/2004 8:17:56 AM
This is probably the most common conceptual part of RS that people miss. The
difference between query parameters and report parameters (and in your case
stored procedure parameters). RS is being nice and creating these things for
you. Not just when you use stored procedures but also when you create any
query with a parameter, it then creates a matching report parameter. But the
point still is that they are two different things (three in the case of
stored procedure). How they are defined, called, tied together is totally up
to you. In report->report parameters you can rename them, remove them,
change the order etc. If renamed, however, they do not fix it up with the
query and you have to go to the dataset, click on the ... and then
parameters tab and map the query parameter to the stored procedure
parameter.

Bruce L-C

"Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.com> wrote in
message news:eBBjJB3fEHA.3632@TK2MSFTNGP09.phx.gbl...
[quoted text, click to view]
Re: Stored procedure parameters and default values Tibor Karaszi
8/11/2004 8:56:10 AM
Thanks Robert. Will check it out.
Being a SQL person, I guess I always try to do things at the SQL level first. :-)

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/


[quoted text, click to view]

Re: Stored procedure parameters and default values Tibor Karaszi
8/12/2004 9:15:53 PM
Yep, I fully understand what you mean, after this day worth of playing with DS parameters vs. Report
parameter.
I removed the DS parameters, couldn't run the DS. Added it back on, setting it to a constant value, DS
executed. Report still showed the parameter (didn't make a difference what I put there), until I removed the
Report parameter. All makes sense now. :-)

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/


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