Question

I wanted to evaluate a simple iif-statement on Transact SQL, but the debugger always returns the message, there's an error near '>'. So I also tried one of the examples, given in the MSDN, but that failed either. These are the statements I want to evaluate separately. The second one is from the MSDN and it fails, too.

select @land + iif(len(isnull(@land, '')) > 0 
and len(isnull(@plz, '')) > 0, ' - ', '') 
+ @plz
SELECT IIF ( 45 > 30, NULL, NULL ) AS Result;

And this is my environment

Microsoft SQL Server Management Studio 10.50.1600.1 
Microsoft Data Access Components (MDAC) 6.1.7601.17514
Microsoft MSXML 3.0 4.0 5.0 6.0 
Microsoft Internet Explorer 9.0.8112.16421
Microsoft .NET Framework 2.0.50727.5420
Operating System 6.1.7601 (Windows 7)
Was it helpful?

Solution

IIF is a new feature of SQL Server 2012 - you cannot use it in 2008 R2.....

This page lists all the new Programmability features of SQL Server 2012 - you'll find IIF under 14 New Functions..... a bit past the middle of the page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top