Professional Web Applications Themes

I need the result set of SP-1 in SP-2, How to get it T-SQL? - Microsoft SQL / MS SQL Server

I need the result set of SP-1 in SP-2, How to get it T-SQL? An SP is written a long time back, and I can not modify it, but I need the result to be used in another Stored Procedure (SP) to do some processing work. For example I need something like this: Create Proc SP1 As Select * from titles. Go Create proc SP2 As Declare x X= SP1 Select * from X Go In example, I have only expressed the main idea, not the actual need....

Sponsored Links
  1. #1

    Default I need the result set of SP-1 in SP-2, How to get it T-SQL?

    I need the result set of SP-1 in SP-2, How to get it T-SQL?

    An SP is written a long time back, and I can not modify
    it, but I need the result to be used in another Stored
    Procedure (SP) to do some processing work.



    For example I need something like this:

    Create Proc SP1
    As
    Select * from titles.
    Go



    Create proc SP2
    As
    Declare x

    X= SP1
    Select * from X
    Go


    In example, I have only expressed the main idea, not the
    actual need.


    Sponsored Links
    joe Guest

  2. #2

    Default Re: I need the result set of SP-1 in SP-2, How to get it T-SQL?

    You can use INSERT ... EXEC to insert the proc results into a table.
    For example:

    CREATE PROC SP2
    AS
    CREATE TABLE #X
    (
    Col1 int,
    Col2 int
    )
    INSERT INTO #X
    EXECUTE SP1
    GO

    --
    Hope this helps.

    Dan Guzman
    SQL Server MVP

    -----------------------
    SQL FAQ links (courtesy Neil Pike):

    http://www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
    http://www.sqlserverfaq.com
    http://www.mssqlserver.com/faq
    -----------------------

    "joe" <com> wrote in message
    news:02fa01c369ed$b0da7ba0$gbl... 


    Dan Guest

  3. #3

    Default Re: I need the result set of SP-1 in SP-2, How to get it T-SQL?

    Thanks Dan Guzman, this is what exactly I wanted, Thank MS.


     
    into a table. [/ref]
    SQL? 
    >
    >
    >.
    >[/ref]
    joe Guest

  4. #4

    Default Re: I need the result set of SP-1 in SP-2, How to get it T-SQL?

    Glad it helped.

    --
    Dan Guzman
    SQL Server MVP


    Dan Guest

Similar Threads

  1. How to get a sum of the result?
    By shearak in forum Coldfusion Database Access
    Replies: 2
    Last Post: March 3rd, 10:00 PM
  2. How big is my result set?
    By Scott Burns in forum Informix
    Replies: 3
    Last Post: September 15th, 11:44 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139