SQL Server 2005- How to prevent Execution – Goto (T-SQL)
I am familiar with Goto Command since i was using Visual Basic 6.0.
I wanted to prevent or bypass the execution in a stored procedure and i used the same command in Sql Server 2005.
Some details:
GOTO skip and processing continues at the label.
GOTO statements can be used any where in the procedure and statement block.
EXAMPLEDECLARE @CLASS INT
SET @CLASS = 4
IF @CLASS = 4
GOTO Class4;
Class1:
SELECT ‘Jumping To Class1.’
Class2:
SELECT ‘Jumping To Class2.’
GOTO Class5;
Class3:
SELECT ‘Jumping To Class3.’
Class4:
SELECT ‘Jumping To Class4.’
GOTO Class2;
Class5:
SELECT ‘Jumping To Class5.’




