IF, WHILE, GOTO, BEGIN/END and other oft-used SQL statements are looked at in detail in this series on query execution.