Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2003
    Location
    Singapore
    Posts
    3

    Unanswered: Is this possible ?

    is it possible to have a select statement from a stored proceedure ? example ...

    CREATE PROCEDURE spA
    SELECT * FROM ( exec spB '1','1' )

    go

    the reason for doing this is becos spB does some data massaging and is used across many stored procedures, spB will be passing back a table if it is possible.

    Thanks.

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    I'd recommend that you rewrite spB as a User-defined table function. Then you can reference it in stored procedures, views, triggers, etc, just like any other table or subquery:

    CREATE PROCEDURE spA
    SELECT * FROM dbo.spB ('1','1')

    blindman

  3. #3
    Join Date
    Dec 2002
    Posts
    29
    Or it that's something you would like to avoid, you could use

    Insert Into #TmpSpB Exec SpB '1','1'


    where #TmpSpB is a temporary table which has the structure of the result return by the stored procedure. The only problem with this, is that can not be nested, and I am not sure if it's working "below" SQL2000.

    Best regards!

  4. #4
    Join Date
    Nov 2003
    Location
    Singapore
    Posts
    3
    thanks for the replies ... you've been a great help ...

Posting Permissions

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