SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


saving variable from a stored proc


saving variable from a stored proc

Author
Message
rs80
rs80
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1914 Visits: 443
Is it possible to replicate this code from a stored procedure in a SSRS dataset?

exec @dtEffective = dbo.selUpdEnv 'PrevBusDt','=',@cdUser,'N'

What I'm trying to do is save the effective date in a variable and display the date in a textbox.

I tried creating a parameter called dtEffective and use it in the dataset. But it didn't save the value.
Luis Cazares
Luis Cazares
SSC Guru
SSC Guru (165K reputation)SSC Guru (165K reputation)SSC Guru (165K reputation)SSC Guru (165K reputation)SSC Guru (165K reputation)SSC Guru (165K reputation)SSC Guru (165K reputation)SSC Guru (165K reputation)

Group: General Forum Members
Points: 165925 Visits: 22823
rs80 - Thursday, September 28, 2017 11:42 AM
Is it possible to replicate this code from a stored procedure in a SSRS dataset?

exec @dtEffective = dbo.selUpdEnv 'PrevBusDt','=',@cdUser,'N'

What I'm trying to do is save the effective date in a variable and display the date in a textbox.

I tried creating a parameter called dtEffective and use it in the dataset. But it didn't save the value.

You need to define it as an OUTPUT parameter to make the stored procedure return the correct value.
exec dbo.selUpdEnv 'PrevBusDt','=',@cdUser,'N', @dtEffective OUTPUT

However, I'm not sure if you need to do something else in SSRS
. You might need to configure something else.



Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
sgmunson
sgmunson
SSC Guru
SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)

Group: General Forum Members
Points: 98212 Visits: 7257
All you need to do is output the input parameter as part of the final SELECT in your stored procedure as a column, and give it a column name. Variables that are passed in to stored procedures are perfectly legal to be in any SELECT anywhere in the stored procedure. Now with that field in the dataset, and named as you saw fit, you can then use that field in any SSRS report.

Steve
‌(aka sgmunson)
Smile Smile Smile
Health & Nutrition
rs80
rs80
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1914 Visits: 443
Thanks for the answers. Unfortunately, it's an existing SP so I can't modify it.
sgmunson
sgmunson
SSC Guru
SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)

Group: General Forum Members
Points: 98212 Visits: 7257
rs80 - Thursday, September 28, 2017 1:07 PM
Thanks for the answers. Unfortunately, it's an existing SP so I can't modify it.

Okay, then what do you mean by "save" that parameter value? Display it in the report? You can create a textbox and have it's value be an expression that references any of the existing report parameters.


Steve
‌(aka sgmunson)
Smile Smile Smile
Health & Nutrition
Thom A
Thom A
SSC Guru
SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)

Group: General Forum Members
Points: 86694 Visits: 22261
sgmunson - Thursday, September 28, 2017 1:44 PM

Okay, then what do you mean by "save" that parameter value? Display it in the report? You can create a textbox and have it's value be an expression that references any of the existing report parameters.

The expression to do so would be (assuming your parameter is called "MyParameter"):
=Parameters!MyParameter.Value


or
=Parameters!MyParameter.Label


Depending on if you want to return the Value or the Label (surprise!) of the parameter.



Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does :-P

Please always remember to encapsulate your code in IFCode Markup. For example [code=sql] [/code].
Click here to read Jeffs Guide on how to post SQL questions, and get swift and helpful answers from the community
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum









































































































































































SQLServerCentral


Search