Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to assign values to null parameters.

Author  Topic 

Johnjonfenomenon
Starting Member

1 Post

Posted - 2004-10-20 : 12:57:22
I am creating a report that needs values to be placed and cannot accept null in fields.

I would like to place zero's if the item comes back null.

SELECT lh.parent, myq.facility, myq.rule, myq.mxlevel
FROM lochierarchy lh, (SELECT substr(location,1,5) as facility, sum(il2) Rule, sum(maxlevel) mxlevel
FROM inventory
WHERE location in (SELECT location
FROM v_storancest
WHERE ancestor = 'NJRAR')
AND substr(itemnum,1,2) <> '62'
GROUP BY location) MYQ
WHERE lh.Location = MYQ.FACILITY
AND lh.systemid = 'MAIN' ORDER BY parent, facility;



thanks in advance

surefooted
Posting Yak Master

188 Posts

Posted - 2004-10-20 : 13:19:57
Use ISNULL. Look it up in Books on line.

-Jon
Now a "Yak Posting Veteran".
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-10-21 : 01:20:35
I prefer COALESCE as it's ANSI compliant and lets you choose from more than 2 values - the first non-null value wins. Bit of a long-winded word though.

Also I personally think IsNull is a stupid name for a function that returns a non-null value, rather than testing whether a value is null - which is what the name implies to me. But that's probably JustMe :-(

Kristen
Go to Top of Page
   

- Advertisement -