Groups | Blog | Home
all groups > sql server programming > june 2004 >

sql server programming : undocumented feature?


James Travis
6/10/2004 3:46:01 PM
From BO

Remark
GOTO can exist within conditional control-of-flow statements, statement blocks, or procedures, but it cannot go to a label outside of the batch. GOTO branching can go to a label defined before or after GOTO
Beeeeeves
6/10/2004 11:36:44 PM
HI
Is it an undocumented feature of SQL server, or just something that 'just
works' that you can use a goto statement, to goto a label that's WITHIN a
while loop!??

Louis Davidson
6/11/2004 8:57:11 AM
I learned something today (and really wish I hadn't)

goto x
select 'hi'

while 1=1
begin
x:
select 'here'
end

This actually will execute the while loop. I figured it would execute the
select 'here' once and be done. Change 1=1 to 1=2, and that is what you
get. Kind of a Do...While <cond> construct.

--
----------------------------------------------------------------------------
Louis Davidson (drsql@hotmail.com)
Compass Technology Management

Pro SQL Server 2000 Database Design
http://www.apress.com/book/bookDisplay.html?bID=266

Note: Please reply to the newsgroups only unless you are
interested in consulting services. All other replies will be ignored :)

[quoted text, click to view]
blocks, or procedures, but it cannot go to a label outside of the batch.
GOTO branching can go to a label defined before or after GOTO.
[quoted text, click to view]

AddThis Social Bookmark Button