Monday, July 25, 2005 5:58:42 PM UTC :: Filed Under SQL

Neither humans nor computes can divide by zero, so if your SQL script has a variable in the denominator of an equation, be sure to safe-guard against a potential divide-by-zero error:

CASE
    WHEN @AveWorkDays = 0 THEN 0
ELSE
    ISNULL(SUM(CAST(ItemInventory.QtyDistributed As decimal))/@AveWorkDays, 0)
END
Comments are closed.
Navigation
On this page....
Search
Archives
<July 2010>
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567
Categories
Contact me
Send mail to the author(s) Contact Todd M. Taylor