saving variable from a stored proc

  • 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.

  • 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
  • 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) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • Thanks for the answers.  Unfortunately, it's an existing SP so I can't modify it.

  • 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) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • 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.
    Larnu.uk

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply