T-SQL 2005 - Divide by zero error encountered

Posted by Grant on Stack Overflow See other posts from Stack Overflow or by Grant
Published on 2010-06-01T23:40:47Z Indexed on 2010/06/01 23:43 UTC
Read the original article Hit count: 163

Filed under:
|
|

Hi, I am trying to get some percentage data from a stored procedure using code similar to the line below. Obviously this is going to cause a (Divide by zero error encountered) problem when base.[XXX_DataSetB] returns 0 which may happen some of the time.

Does anyone know how i can deal with this in the most efficient manner?

Note: There would be about 20+ lines looking like the one below...

cast((base.[XXX_DataSetB] - base.[XXX_DataSetA]) as decimal) / base.[XXX_DataSetB] as [XXX_Percentage]

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server-2005