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.
| Author |
Topic |
|
skillile
Posting Yak Master
208 Posts |
Posted - 2002-01-28 : 13:39:41
|
| --I have a list of 20 numbers to add--how can I add the vars and get a --value some are nulldeclare @x intdeclare @y intdeclare @z intset @x=nullset @y=1set @z=1select @x+@y+@z--i want the answer to be 2--Thanksslow down to move faster... |
|
|
chadmat
The Chadinator
1974 Posts |
Posted - 2002-01-28 : 13:56:27
|
| Use the IsNull function.It converts NULL values to whatever you want them to be before adding them. So if they should be 0, then you would put:Select isnull(@x, 0) + isnull(@y, 0) + isnull(@z, 0)The answer would be 2-Chad |
 |
|
|
|
|
|