Passing SELECTed rows to a calling SP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • NiTiN

    Passing SELECTed rows to a calling SP

    Hi!

    I'm a new T-SQL developer and just hit a roadblock.

    I have a scenario that goes like this: I have 2 stored procedures,
    spInner and spOuter. spInner has a SELECT statement which would
    normally be used by a class using MS Enterprise Library and that output
    goes into a DataSet. However, I need to get the output of the SELECT
    statement to go into spOuter and that's what I can't seem to figure
    out.

    I know I may be asked to use functions that return tables in replies to
    this post, but I can't do that as some parts of my application have an
    EXEC(string) for dynamic SQL, instead of spInner.

    Any help appreciated.

    Cheers,
    N.I.T.I.N.

  • Paul Ibison

    #2
    Re: Passing SELECTed rows to a calling SP

    For the results of spInner to be available to spOuter, there are a few
    options. I have used temporary tables or persisted the data into a real
    table to avoid recompiles and also have a record of the data. If you use the
    latter option, you can use a guid column and each row with a guid obtained
    from spOuter. This way you can easily pick up the rows you need.
    Cheers,
    Paul Ibison SQL Server MVP, www.replicationanswers.com


    Comment

    • Erland Sommarskog

      #3
      Re: Passing SELECTed rows to a calling SP

      NiTiN (emailme.nitin@ gmail.com) writes:
      I'm a new T-SQL developer and just hit a roadblock.
      >
      I have a scenario that goes like this: I have 2 stored procedures,
      spInner and spOuter. spInner has a SELECT statement which would
      normally be used by a class using MS Enterprise Library and that output
      goes into a DataSet. However, I need to get the output of the SELECT
      statement to go into spOuter and that's what I can't seem to figure
      out.
      >
      I know I may be asked to use functions that return tables in replies to
      this post, but I can't do that as some parts of my application have an
      EXEC(string) for dynamic SQL, instead of spInner.
      I have an article on my web site that discusses possible options. See
      http://www.sommarskog.se/share_data.html.



      --
      Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

      Books Online for SQL Server 2005 at

      Books Online for SQL Server 2000 at

      Comment

      Working...