Home Forums SQL Server 2008 T-SQL (SS2K8) eliminating divide by zero error RE: eliminating divide by zero error
PhilPacha
Hall of Fame
Points: 3645
More actions
October 22, 2014 at 12:12 pm
#1754148
What about [YourNumerator] / NULLIF([YourDivisor], 0) ? If the divisor is zero, it become null, and the result is null. Then handle the null quotient in the method best suited to the circumstances.