954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

The isnull function requires 2 argument(s).

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. .

aplee
Light Poster
28 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

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]
Fenrir()
Newbie Poster
20 posts since Jan 2011
Reputation Points: 18
Solved Threads: 5
 

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?

adam_k
Practically a Posting Shark
803 posts since Jun 2011
Reputation Points: 256
Solved Threads: 149
 

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!

aplee
Light Poster
28 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

Done adding reputation :)

aplee
Light Poster
28 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You