sql server 2012 iif incorrect syntax
-
Friday, March 22, 2013 12:26 AM<p>I have recently installed sql server 2012 on a pc which had sql server 2005 previously.</p><p>I was trying to execute the iif function as a query from Management Studio.</p><p><span style="color:#0000ff;font-face:Consolas;font-size:small;"><span style="color:#0000ff;font-face:Consolas;font-size:small;"><span style="color:#0000ff;font-face:Consolas;font-size:small;"> </span></span></span></p><p><span style="color:#0000ff;font-face:Consolas;font-size:small;"><span style="color:#0000ff;font-face:Consolas;font-size:small;"><span style="color:#0000ff;font-face:Consolas;font-size:small;">select iif(45>40,'true','false'</span></span></span></p>
All Replies
-
Friday, March 22, 2013 12:48 AM
after seeing what was posted thought i'd restate the question hopefully without all the xml gumph
I have recently installed sql server 2012 on a pc which had sql server 2005 previously.
I was trying to execute the iif function as a query from the 2012 Management Studio.
select iif(45>40,'true','false') as result
which returns the result "Incorrect Syntax near '>'."
I still have SQL Server 2005 on my PC. Do I need to completely remove SQL Server 2005 from my PC? Is there something I need to do to enable 2012 functionality?
-
Friday, March 22, 2013 12:55 AM
Check the examples in BOLs ( http://msdn.microsoft.com/es-mx/library/hh213574.aspx ) and you need to check if you are really connecting your SQL SERVER 2012 instance, because if you are connecting to your SQL SERVER 2005 instance, you will get that error.
Sergio Sánchez Arias
AYÚDANOS A AYUDARTE

- Edited by SergioSA(chancrovsky)Microsoft Community Contributor Friday, March 22, 2013 12:57 AM
- Proposed As Answer by Naomi NMicrosoft Community Contributor, Moderator Friday, March 22, 2013 4:32 AM
- Marked As Answer by Allen Li - MSFTModerator Monday, April 01, 2013 9:48 AM
-
Friday, March 22, 2013 1:07 AM
Thanks Sergio
Yes I was connected to the sql server 2005 instance through Management Studio
-
Friday, March 22, 2013 1:27 AM
after seeing what was posted thought i'd restate the question hopefully without all the xml gumph
I have recently installed sql server 2012 on a pc which had sql server 2005 previously.
I was trying to execute the iif function as a query from the 2012 Management Studio.
select iif(45>40,'true','false') as result
which returns the result "Incorrect Syntax near '>'."
I still have SQL Server 2005 on my PC. Do I need to completely remove SQL Server 2005 from my PC? Is there something I need to do to enable 2012 functionality?
Try
select case when 45>40 then 'true' else 'false' end as result
go
instead
Many Thanks & Best Regards, Hua Min
-
Friday, March 22, 2013 6:07 PMAlthough you are using 2012 to connect to 2005, IIF is introduced in 2012. 2005 parser will not recognize IIF

