Divide by zero error | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Divide by zero error

Hi, I have two environment, one is my test and other is my development. I am getting below error in test Divide by zero error encountered.
but same error i am not getting in my development environment with similar data. Do you know any way to stop above errors. Thanks and Regards Ravi K
Hi ya, presumably this is as a result of a statement? if so, then could you let us know what the statement is? The basic answer will probably be to use a CASE clause within the statement to check for the divisor being 0 and returning a value rather than performing the division… Cheers
Twan

I don’t think you have same data in both places do some thing like this Select DIV,Area, Case When Print_Sol = 0 Then 0
Else Print_Cart / Print_Sold End As Printer From Application_Currys.Attach_Emp
—————————————-
Cast your vote
http://www.geocities.com/dineshasanka/sqlserver05.html http://spaces.msn.com/members/dineshasanka

Add a check for the zero situation before the offending piece of code, and handle accordingly. And you should have added this in the first place.[8D]
Post the code you used Madhivanan Failing to plan is Planning to fail
Check settings on ‘arithabort’ values. Satya SKJ
Moderator
http://www.SQL-Server-Performance.Com/forum
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.
AFAIK, using SET ARITHABORT will owkr only for INSERT, DELETE or UPDATE from BOL When an INSERT, DELETE or UPDATE statement encounters an arithmetic error (overflow, divide-by-zero, or a domain error) during expression evaluation when SET ARITHABORT is OFF, SQL Server inserts or updates a NULL value. If the target column is not nullable, the insert or update action fails and the user receives an error. —————————————-
Cast your vote
http://www.geocities.com/dineshasanka/sqlserver05.html http://spaces.msn.com/members/dineshasanka

]]>