It's very useful, but - in my opinion - is somehow 'dirty'.
You may, always, use
NULLIF operator, ie:
DECLARE @dividend INT ,@divisor INT
SET @dividend = 1
SET @divisor = 0
SELECT @dividend / NULLIF(@divisor, 0)
which will lead you to
NULL when divisor is equal to 0.
commented on Feb 23 2012 3:04AM