tony@kenny.net (1/3/2013)
My question: Which way do you swing? Do you have any other ways? Any other comments welcome.
FWIW, this is how I'd probably do it. I like to get rid of NULLs as early as possible in a procedure so I don't have to use "Where X IS [NOT] NULL" syntax. Sometimes NULLs are unavoidable and of course this snippet assumes an INT key > 0.
DECLARE @id INT
SET @id = ISNULL(@id,0)
IF @id < 0 SET @id = 0
UPDATE myTable
SET ClearFlag = 1
WHERE
(ID = @id)
OR
(ClearFlag = 0 AND @id = 0)