There are multiple variations of IF statements: The simple IF
construct is used to evaluate a Boolean condition and execute an
appropriate set of commands. For instance the following example
determines whether the current day of the week is Friday: IF
DATEPART(dw, GETDATE()) = 6 BEGIN PRINT 'TGI Friday' END We can
easily extend the same construct by adding an ELSE clause to
take the alternative course of action and calculate the number
of days before Friday: IF DATEPART(dw, GETDATE()) = 6 BEGIN
PRINT 'TGI Friday' END ELSE BEGIN SELECT 'Sorry, Friday is ' +
CONVERT(VARCHAR(1), (6-DATEPART(dw, GETDATE())) )+ ' days away'
END Alternatively we can determine the Boolean value of a
condition based on the outcome of a SELECT statement: IF (SELECT
COUNT(*) FROM authors) > 20 PRINT 'authors table contains more
than 20 records' Note: If you wish to execute multiple
statements depending on the value of a condition, be sure to
enclose those statements within a BEGIN END block ometimes you
have to check for multiple condi