How to figure this one out - "The isnull function requires 2 argument(s)"

H

Hexman

Hello All,

In SS EE I have nulls in a column. I want to select and eventually change to a zero (its a smallint column). I've tried selecting 'null', 'dbnull',
etc. Then I read about the ISNULL function. From the example I got, I received the "...requires 2 arguments...." error. Read up on it but it
doesn't click with me.

Could someone explain the error? And secondly, how to select null fields?

Thanks,

Hexman

====================== Code Below ================
use CNDB
select * from cnmaster
where isnull(cnpick)

Msg 174, Level 15, State 1, Line 3
The isnull function requires 2 argument(s)
 
G

GhostInAK

Hello Hexman,

SELECT * FROM Table WHERE Field IS NULL

The change to zero SQL looks like:
UPDATE Table SET Field = 0 WHERE Field IS NULL

The ISNULL function converts a null value into a non-null value.. so..
SELECT Field AS NullField, ISNULL(Field, 0) AS NotNullField FROM Table
....would return ALL records, but report any null values in Field as zero,
without changing the underlying data.

ISNULL() is a reporting function.. not a data changing function.

-Boo
 
H

Hexman

Works beautifully! Thanks a bunch.

Hexman


Hello Hexman,

SELECT * FROM Table WHERE Field IS NULL

The change to zero SQL looks like:
UPDATE Table SET Field = 0 WHERE Field IS NULL

The ISNULL function converts a null value into a non-null value.. so..
SELECT Field AS NullField, ISNULL(Field, 0) AS NotNullField FROM Table
...would return ALL records, but report any null values in Field as zero,
without changing the underlying data.

ISNULL() is a reporting function.. not a data changing function.

-Boo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top