Use control-of-flow language with interactive statements, in batches, and in stored procedures.
This table lists the control-of-flow and related keywords and their functions.
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 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. |