Treating null field as zero for an update query
问题 I'm using the SQL Express 2010 query builder. I need to be able to increment a field. In my behind code, I make a call such as tableAdapter.IncrementLikeCount(id); If I just use an increment, the like field can be null, so I want to either a. treat the null as zero in that field OR b. set to 1, if null, and increment otherwise. The most current thing I tried is option b with the following code in the query builder: UPDATE [dbo].[myTable] SET [LikeCount] = IIF(ISNULL([LikeCount]), 1, LikeCount