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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

return 0 when nothing or null

Status
Not open for further replies.

bmpsu

Programmer
Jan 13, 2005
128
US
I have a query I need to return a 0 if the value is NULL or non-existent. This is my query and it seems to work. I wanted to see if any experts out there have a better way.

sql server 2000

SELECT COALESCE(MAX(CONVERT(INT,variableValue)),0) FROM sysVar WHERE variableName = 'minThreshold'

If variableValue is null or if variableName 'minThreshold' is non-existent in sysVar, this query will return 0 as I need it to do. Is this the correct way to do this?

Thanks
 
Thanks. I just wanted to make sure there wasn't a better or correct way to achieve this.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top