Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2005
    Posts
    37

    Unanswered: passing value from stored proc to another

    Guys
    I have a simple 'black box' proc deriving start and end dates below (the actual values will be derived from more complex code but here for simplicity are hard coded)

    create proc upGetDates
    as
    declare @start datetime ,
    @end datetime

    select @start = '2001-01-01' ,
    @end = '2007-12-31'
    go


    I want to reuse this proc many times for different reports and using the date values in the calling sp

    an example in pseudo code would be

    create proc usedates
    as
    declare@rstart datetime ,
    @rend datetime

    exec upGetDates @rstart = @start , @rend = @end -- obtaining dates from ---called 'black box' proc
    select * from tablename where datecreated >= @rstart and datecreated < @rend
    go


    Not sure how to 'trap' the dates from the called proc

    Can it be done ?

    Thanks in anticipation

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    you maybe want to use output parameters in your "black box" sp.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Oct 2005
    Posts
    37

    Thumbs up

    That's great - thanks.

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    you maybe want to create this as user-defined functions instead.

    This is what UDFs were intended to do.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •