0

Hello Everyone,
I know this is going to be easy to all of you, this is my first time performing an if else statement in SQL,
after performing this query:

Collapse | Copy Code
IIf(IsNull(EventSummary.[Event Information - Event Status]),"ACTIVE",EventSummary.[Event Information - Event Status]) AS [Event Status],
I get this error message:
Msg 174, Level 15, State 1, Line 2
The isnull function requires 2 argument(s).

I just want to perform a query that will select the event status, check if it is null, if it is null, then value of event status should be active, else, just copy the value of event status.

I hope you can help me.
Thanks. .

3
Contributors
4
Replies
7
Views
6 Years
Discussion Span
Last Post by aplee
1

Maybe something along these lines rather?

SELECT (CASE WHEN COALESCE((EventSummary.[Event Information] - EventSummary.[Event Status]),0) = 0 THEN 'ACTIVE' ELSE (EventSummary.[Event Information] - EventSummary.[Event Status]) END) AS [Event Summary]
1

I'm guessing that your field is EventSummary.[Event Information - Event Status], so I'll suggest

isnull(EventSummary.[Event Information - Event Status],'ACTIVE')

This in SQL will instruct the server to check if the field is null and if it is return ACTIVE. If the field is not null the it will return the value in the field.

PS: Have you googled isnull?

Votes + Comments
added 1 for you! great answer!
0

I'm guessing that your field is EventSummary.[Event Information - Event Status], so I'll suggest

isnull(EventSummary.[Event Information - Event Status],'ACTIVE')

This in SQL will instruct the server to check if the field is null and if it is return ACTIVE. If the field is not null the it will return the value in the field.

PS: Have you googled isnull?

That solved my problem, thanks a ton!

0

Done adding reputation :)

Edited by aplee: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.