ELIMINATE DIVIDE BY ZERO


By Jason S
Printer Friendly Version
  

To Eliminate the divide by zero error in a calculation in SQL 2005.



To Eliminate the divide by zero error in a calculation in SQL 2005 use the following:

DECLARE @a money, @b int
SELECT @a=1, @b=0
SELECT     ISNULL(@a/NULLIF(@b,0),0)



button
 
Article Discussion: ELIMINATE DIVIDE BY ZERO
Jason S posted at 18-Jun-08 01:54
Original Article