Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Divide by zero

Author  Topic 

vladimir_grigoro
Yak Posting Veteran

62 Posts

Posted - 2004-07-12 : 03:09:39
Is there any chance to solve this problem:

Server: Msg 8134, Level 16, State 1, Procedure XXX, Line 19
Divide by zero error encountered.

I mean to hide this error to solve the problem in other way?

The Rebel

ravilobo
Master Smack Fu Yak Hacker

1184 Posts

Posted - 2004-07-12 : 03:44:48
How u got this error? Can you post the sql...

------------------------
I think, therefore I am
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-07-12 : 03:47:44
I think it's best to handle the zero divide in your code:

create table #test(Val1 int, val2 int)

insert into #test values(10, 0)
insert into #test values(10, 2)


select case when val2 = 0 then 0 else val1 / val2 end
from #test

drop table #test

--****** The other option would probably be to:
set arithabort off

This is not recomended though.


Duane.
Go to Top of Page
   

- Advertisement -