I am using SQL Express 2010 query builder. I need to refine the field.
In my code behind I call, for example
tableAdapter.IncrementLikeCount(id);
If I just use the increment, then such a field can be null, so I want either a. treat zero as zero in this field OR b. set to 1 if null, and increment otherwise.
The very last thing I tried is option b with the following code in the query builder:
UPDATE [dbo].[myTable] SET [LikeCount] = IIF(ISNULL([LikeCount]), 1, LikeCount + 1) WHERE ([ID] = @Original_ID)
However, this does not work. The query designer continues to rewrite the expression inside ISNULL without square brackets and with a comma, as shown below:
UPDATE [dbo].[myTable] SET [LikeCount] = IIF(ISNULL(LikeCount,), 1, LikeCount + 1) WHERE ([ID] = @Original_ID)
Is there a simple and easy way to do this?
increment dbnull sql-server-express query-builder
elbillaf Feb 03 2018-12-12T00: 00Z
source share