Can This Work?

  • sgmunson (3/13/2013)


    And why isn't anyone making a lot more noise about it?

    Because it's not really important? Because we're all grateful for the free service that Steve provides, and the time and effort spent by all the question setters?

  • Christian Buettner-167247 (3/1/2013)


    demonfox (2/28/2013)


    tom.kane (2/28/2013)


    I got tricked with this one. I said No, because the code will cause a syntax error as you can't mix creating tables and procs without using a GO

    I guess I should have been looking at the bigger picture :blush:

    well, I think that's not the case .. It does create the stored procedure without the GO ..

    One thing that could have caused a confusion was SP1 creating when SP2 is not created ; It gives a Warining , not an error , then creates the store procedure ...:-D

    No, the procedure is not created:

    Msg 111, Level 15, State 1, Procedure sp1, Line 12

    'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.

    Msg 156, Level 15, State 1, Procedure sp1, Line 17

    Incorrect syntax near the keyword 'proc'.

  • Christian Buettner-167247 (3/1/2013)


    demonfox (2/28/2013)


    tom.kane (2/28/2013)


    I got tricked with this one. I said No, because the code will cause a syntax error as you can't mix creating tables and procs without using a GO

    I guess I should have been looking at the bigger picture :blush:

    well, I think that's not the case .. It does create the stored procedure without the GO ..

    One thing that could have caused a confusion was SP1 creating when SP2 is not created ; It gives a Warining , not an error , then creates the store procedure ...:-D

    No, the procedure is not created:

    Msg 111, Level 15, State 1, Procedure sp1, Line 12

    'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.

    Msg 156, Level 15, State 1, Procedure sp1, Line 17

    Incorrect syntax near the keyword 'proc'.

    Not sure how you are executing. It does create procedures. Like Tom mentioned, when you create SP1, it is calling SP2 which is not existed yet and throws warning but it does create procedure SP1.

    The question says "Will this code execute and return a result from one of the stored procedures?". The answer is "yes", it does executes and returns result but throws error after reaching MAX SQL Server infinite loops. Should have presented question in different way or should have answer choice presented differently.

  • sbamaty (3/14/2013)


    Not sure how you are executing. It does create procedures. [...]

    The question has been updated after my response. The original version did not include the batch separators. The new version does indeed create the procedures.

    Best Regards,

    Chris Büttner

  • Another case of unclear question.

    Will this code execute and return a result from one of the stored procedures?

    Both

    3. No, this will create an infinite loop (until the limitations of SQL Server end it)

    4. Yes

    are right. We have a loop and we have result.

    Moderator suppose to check questions.

  • Artur Komkov (3/24/2013)Moderator suppose to check questions.

    User supposed to read thread before posting exactly the same reply as 8 pages of other people 😉

  • 51% errors at 04/02/2013

    and a lot of bad loosers !!

    when I poorly read , I assume my errors perhaps can you too ?

  • Good one.

  • I thought so.

    But I'm always aware of some unexpected behaviour.

    Expect the unexpected

  • infinite loops. My exec of the SP stops already after 32 loops.

  • ArnoKwetters (6/22/2015)


    infinite loops. My exec of the SP stops already after 32 loops.

    That's the limit for depth of calls in a stack.

Viewing 11 posts - 76 through 85 (of 85 total)

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