IIF :- New function in sql server denali


We all are aware of IIF, but its not available in previous version of SQL Server
Now its available in  Denali.




Syntax

IIF ( boolean expression, true value , false value )


Example

If the table is created before 2011-01-01 we want to identify its as old tables else new tables

Lets see how we can do it using IIF

SELECT Iif (create_date < '2011-01-01', 'New Table', 'Old Table'),
       *
FROM   sys.objects




No comments:

Post a Comment

Popular Posts