Tuesday, June 9, 2009

Solution to SQL Server Error "Divide by zero error encountered"

DECLARE @input int
SET @input = 25*5
SELECT (CASE @input when 0 then 1 else @input end)

SELECT (CASE 25/0 when 0 then 1 else 25/0 end)