Increment int by 1 in sql server?

null, sql, sql-server

Solution

Use ISNULL operator like:

ISNULL(your_field, 1)

Try following:

Select ISNULL(Max(iCategoryOrder), 0) + 1  
from [IVRFlowManager].[dbo].[tblCategory]  
where iCategoryLevel = 1 

Problem

How can I return `1` if the SQL below returns `NULL`? Something like (pseudo code): ``` if sql return NULL value then set value to one otherwise returning sql result value. ``` Is there any SQL for defining default value to 1 if SQL result is NULL? ``` SELECT Max(iCategoryOrder)+1 FROM [IVRFlowManager].[dbo].[tblCategory] WHERE iCategoryLevel = 1 ```

Original source