January 29, 2013 at 4:41 am
Folks,
I am using SQL Server 2012 Express Edition and want to make use of the new IIF-function. I am using the following code:
IIF(Rank=1,'Gold',IIF(Rank =2,'Silver', 'Bronze'))
Rank is a databasefield.
My problem is that (when working in the criteria pane of Studio) I am getting the following error:
An expression of non-boolean type specified in a context where a condition is expected, near '('
It looks like IIF is not recognized??
Working in de sql pane of Studio the error is something like:
Error in list of function arguments: '=' not recognized.
Unable to parse query text..
I have tried almost everything to get the problem solved, but nothing seems to work.
Can anyone get me out of this mess?
Grz,
Robert
January 29, 2013 at 4:50 am
no longer applicable
January 29, 2013 at 6:04 am
IIF is a function that is used to return a value. Just like other functions (for example getdate()), it can't be written on its own without setting it's value to a variable or without select statement that is using it. See my code example:
create table MyTable (Rank int);
insert into MyTable values (1),(2),(3);
select IIF(Rank=1,'Gold',IIF(Rank =2,'Silver', 'Bronze'))
from MyTable;
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
January 29, 2013 at 6:14 am
Adi,
Thanks: everything is working well now. I apologize for the mixing up the threads.
Grz,
Robert
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy