SQLTeam.com | Weblogs | Forums

Dividing 0 by 0


#1

hi

in ssis i have been asked to divide one column by another. it keeps erroring out as something both columns have 0 in them is there anyway around this.


#2

Divide by zero is the problem. Numerator being zero would not cause any errors. To avoid division by zero, you should use a derived column transformation such as
Denominator == 0 ? NULL(DT_I8) : Denominator

If you indeed want to calculate the 0/0, that would involve a little bit of math ( L'Hospial's rule and such), which is beyond the scope of this forum.


#3

is there a way of coding somethig like this in ssis

IF (Cost = 0, 0, MV / Cost)


#4

Are you sure you want 0 in that scenario? I use NULL (as per the code that James proposed)

Otherwise use the syntax James proposed and just change it to use your objects [Cost] and [MV]