Home Forums SQL Server 7,2000 General How to Pass One SP’s Result as Another SP’s Parameter. RE: How to Pass One SP’s Result as Another SP’s Parameter.

  • You can use the INSERT... EXEC... construct to save the results of stored proc BB into a temp table, then read from that. You'll need the @name parameter to pass into BB though, your sample code didn't show where that came from.

    Something like:

    create proc BB

    @name varchar(50)

    as

    select cep from table where name = @name

    go

    create proc AA

    as

    begin

    create table #result (cep int)

    insert into #result exec BB @name

    select top 1 @cep = cep from #result

    if @cep > 1000

    select table1000

    else

    select table1001

    drop table #result

    end

    go

    https://technet.microsoft.com/en-us/library/aa175921(v=sql.80).aspx