Passing expression to an stored procedure

  • Is there a way to pass an expression to a stored procedure.

    Ex. stored procedure usp_XXX is expecting numeric parameters

    exec usp_xxxx 9.9 works fine,

    What want is...

    exec usp_xxxx @x * 2.5 (@x is variable declared as dec(8,0)

    I know, I can set @x = @x * 2.5 and then exec usp_XXXX @x

  • mind me asking why you would need to pass an expression to a stored proc?


    Everything you can imagine is real.

  • The stored procedure is used in triggers on multi-databases.  In most cases, there is not a need to pass it an expression.  The developer did not want to have to create new variables to hold the results of the expression to pass to the stored procedure.

  • How come you don't want to do it the way you show in your example?  That is to set the value of the variable to whatever you want and then pass the variable.

  • The exact thing the developer is trying to avoid doing here is the way to do it.  Why would the developer want to avoid creating a variable to hold this in?  I don't get it.  That's what variables are for right?

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • John,

    my thought as well.why should a developer not want to do it. i thot that was part of the job spec.


    Everything you can imagine is real.

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

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