Monday, March 26, 2012

IF (SQL server)

How can I make something that in MS Access query looks like this:
SELECT IIF([Amount] Is Not Null,Amount,0) AS PayedAmount ...

Regards,
MarkonniUse CASE as a general replacement for IIF. In this instance though you
can use COALESCE:
SELECT COALESCE(amount,0) ...

--
David Portas
SQL Server MVP
--|||Thank you!

"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1109093023.132174.307660@.z14g2000cwz.googlegr oups.com...
> Use CASE as a general replacement for IIF. In this instance though you
> can use COALESCE:
> SELECT COALESCE(amount,0) ...
> --
> David Portas
> SQL Server MVP
> --sql

No comments:

Post a Comment