Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am trying to add 1 to a fieldvalu

Status
Not open for further replies.

redtoad

Programmer
Jan 28, 2002
51
US
I am trying to add 1 to a fieldvalue. This works great except when a null value is returned. How do I set a null value to 0? I tried using the ISNULL function but kept getting a null value returned.


Select top 1 num.fieldvalue + 1 as 'num.fieldvalue'
FROM blah blah blah


Thanks.
 
Try something like this:

SELECT TOP 1 IsNull(num.fieldvalue,-1) + 1 AS 'num.fieldvalue' FROM blah blah blah

--Angel
-----------------------------------
SELECT * FROM users WHERE clue > 0
0 row(s) selected
 
Actually, the issue is, and I didn't metion this before, that there is no row given the constraints. I need to insert a row with num.fieldvalue of 1 if there is no row. So I think I will be able to do that by evaluating the query, then inserting a row if none is returned.

Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top