locked
GOTO statement RRS feed

  • Question

  • i am trying to do like this in stp


    GOTO Branch_One
    SELECT 'next'

    Branch_One:
    SELECT 'Branch One.'


    is it possible to return control back to next statement comes after GOTO Branch_One statement

    Wednesday, April 4, 2012 4:14 PM

Answers

  • Please do not use GOTO statements - ever.    Can you post the logic of what you are actually trying to accomplish?

    Chuck

    • Proposed as answer by Naomi N Wednesday, April 4, 2012 4:39 PM
    • Marked as answer by KJian_ Wednesday, April 11, 2012 3:39 AM
    Wednesday, April 4, 2012 4:16 PM

All replies

  • Please do not use GOTO statements - ever.    Can you post the logic of what you are actually trying to accomplish?

    Chuck

    • Proposed as answer by Naomi N Wednesday, April 4, 2012 4:39 PM
    • Marked as answer by KJian_ Wednesday, April 11, 2012 3:39 AM
    Wednesday, April 4, 2012 4:16 PM
  • Hi,

    I second chuck on this one. Please refrain from using GOTO unless you have exhausted all possible alternatives ! If you have give us more details on the logic you are trying to implement, we can try to suggest alternatives.


    Sanil Mhatre | Database Developer | MCTS | If you find my reply useful in any way, please vote it as helpful. If it has helped answer your question, please mark it as Answer.

    Wednesday, April 4, 2012 4:22 PM
  • Is it possible?  Yes.  You can use GOTO to jump between any two points in a script, forwards or backwards.  Should you do this?

    NO!!!

    Wednesday, April 4, 2012 4:24 PM
  • Yes, you can use GoTo statement to jump back & forth.

    Pratik V Patel

    Friday, April 6, 2012 10:10 AM
  • I cannot believer that anyone would post this in 2012!  The entire 1970's Structured Programming revolution  based on getting rid of the GOTO.  Start with the classic paper and then try to catch up everything that has happened after punch cards. 

    http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html 

    Manna's book is also available from Dover Books, if you like the math.  


    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking in Sets / Trees and Hierarchies in SQL

    Friday, April 6, 2012 6:10 PM