Sybase Technical Library - Product Manuals Home
[Search Forms] [Previous Section with Hits] [Next Section with Hits] [Clear Search] Expand Search

Rules associated with batches [Table of Contents] Local variables

Transact-SQL User's Guide

[-] Chapter 13 Using Batches and Control-of-Flow Language
[-] Using control-of-flow language

Using control-of-flow language

Use control-of-flow language with interactive statements, in batches, and in stored procedures. Table 13-1lists the control-of-flow and related keywords and their functions.

Control-of-flow and related keywords

Keyword

Function

if

Defines conditional execution.

...else

Defines alternate execution when the if condition is false.

case

Defines conditional expressions using when...then statements instead of if...else.

begin

Beginning of a statement block.

...end

End of a statement block.

while

Repeat performance of statements while condition is true.

break

Exit from the end of the next outermost while loop.

...continue

Restart while loop.

declare

Declare local variables.

goto label

Go to label:, a position in a statement block.

return

Exit unconditionally.

waitfor

Set delay for command execution.

print

Print a user-defined message or local variable on user's screen.

raiserror

Print a user-defined message or local variable on user's screen and set a system flag in the global variable @@error.

/* comment */or --comment

Insert a comment anywhere in a Transact-SQL statement.

if...else
[-] case expression
Using case expression for alternative representation
case and division by zero
Using rand() functions in case expressions
case expression results
case expression requires at least one non-null result
case
case and value comparisons
coalesce
nullif
begin...end
while and break...continue
declare and local variables
goto
return
print
raiserror
Creating messages for print and raiserror
waitfor
[-] Comments
Slash-asterisk style comments
Double-hyphen style comments


Rules associated with batches [Table of Contents] if...else