SQL increment integer column even if null

sql-server, sql-server-2008

Solution

UPDATE entity_table
SET    views = Coalesce(views, 0) + 1

Problem

I have this SQL: ``` update entity_table set views = views + 1 where id = {id of entity} ``` the views column is nullable. So this only works if the column has a value which is not null. How can I make this statement set the value to 1 if it is null and increment otherwise? Thanks.

Original source

Related problems