IIF statement in SQL Server 2005

iif, sql-server, sql-server-2005

Solution

That `IIF` statement only exists in MDX - the query language for SQL Server Analysis Services - the datawarehousing side of SQL Server.

Plain T-SQL does not have an `IIF` statement.

The best you can do in T-SQL is use the `CASE.... WHEN... THEN...` statement.

Problem

Does `IIF` statement exists in all version of SQL Server ? I have checked a tutorial on MSDN. But when I tried to run this code on my machine ``` DECLARE @newDate datetime SET @newDate = CONVERT(varchar, {fn NOW()}, 111) SELECT IIF(@newDate > '2010/12/2', 'Greater', 'smaller') ``` But I am getting error of "Incorrect syntax near '>'." Can someone provide me an example in SQL Server 2005 for the existence of the `IIF` statement?

Original source