The IF statement is used to test for a condition. The resulting flow of control ... Using IF...ELSE. SQL Server 2008 R2.
technet.microsoft.com