Home Forums SQL Server 2008 SQL Server 2008 - General Computed Columns & Divide By Zero Errors RE: Computed Columns & Divide By Zero Errors
Ant-Green
SSC Guru
Points: 113445
More actions
January 14, 2013 at 6:22 am
#1576855
So the computed column is ColA / ColB, what do you want the output to be.
If ColA is 10 and ColB is 0, do you want the computation to be 10 or 0
For 0
ISNULL(ColA / NULLIF(ColB, 0), 0)
For 10
ColA / ISNULL(NULLIF(ColB,0), 1)