Nested Procedures

  • Can anybody point me at a good guide to using nested procedures please? There's a lot on the web but it all seems to assume background knowledge of using them. Books Online just says that you can call one proc from within another but doesn't explain how or give examples of syntax.

    I'm confused by the fact that all the articles and examples seem to have some element of creating procs. It seems if I want to call a proc that's already there then I shouldn't necessarily have to create anything.

    I'm pretty sure I'm missing something really obvious but I'm stumped.


    On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" ... I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
    —Charles Babbage, Passages from the Life of a Philosopher

    How to post a question to get the most help http://www.sqlservercentral.com/articles/Best+Practices/61537

  • It's simply a matter of executing the procedure inside your stored proc.

    CREATE PROCEDURE MyNewProc

    AS

    EXEC AlreadyExistingProc;

    GO

    If you need to manipulate the data returned from a stored proc you can use a temp table

    CREATE PROCEDURE MyNewProc

    AS

    CREATE TABLE #MyTemp (ColumnList);

    INSERT INTO #MyTemp

    EXEC AlreadyExistingProc;

    GO

    The SQL Guy @ blogspot[/url]

    @SeanPearceSQL

    About Me[/url]

  • That, Sean, is exactly what I wanted. I had a feeling it was something as simple and straightforward as that. With all the flim-flammery around many of the examples and explanations it was hard to make it out though.

    Within thirty seconds of your answer I'd got the proc I wanted to provide the result I wanted. The fact it's not the result I needed is for another question.

    Thanks for your help.


    On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" ... I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
    —Charles Babbage, Passages from the Life of a Philosopher

    How to post a question to get the most help http://www.sqlservercentral.com/articles/Best+Practices/61537

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply