Friday, February 24, 2012

IIF Statement in Query designer

Hello,

I am trying to use following IIF Statement in Query designer but getting error message saying "Incorrect syntax

near '>')

Can anyone please help, perhaps correct the statement for me?

IIF([Expected Receipt Date] > now(), 1, 0) AS EXPR1

Thank you in advance

-- Praf

the Query Designer uses SQL

Try a Case Statement instead of the IIF statement

example

CASE

WHEN [Expected Receipt Date] > getdate() THEN 1

Else 0

END as EXPR1

|||

Charles is correct; IFF is available in Report Services but is NOT part of the Transact SQL language. If you are going to edit this query from the Query Designer then CASE syntax is a good choice.

( OK, I am confused with this; where am I going wrong with this? )

|||

I tried the case statement,

I error "The Query Designer does not support the CASE SQL construct." but did provide the results.

Also I am building this query in Query designer.

Thanks

|||

Your code seems like a mix between SQL and RS expressions. To use expressions, you must have the = sign in front of the query. This will allow you to build the SQL statement by concatenating strings, using the IIF expression if needed.

Michael

No comments:

Post a Comment