Mega Code Archive

 
Categories / MSSQL Tutorial / Transact SQL
 

The syntax of the IF ELSE statement

IF A=B    Statement when True ELSE    Statement when False To batch statements together within an IF ELSE, we must surround the code with a BEGIN…END block. An example of how the code would look follows: IF A=B    BEGIN       Statement when True       Another statement when True       Yet Another True statement    END ELSE    False statement 6> IF 12.0 > 10E 7>   PRINT 'Bigger' 8> ELSE 9>   PRINT 'Smaller'; 10> GO Bigger