Solved

Divide by zero, but I still want the sp to execute

Posted on 1998-02-16
2
202 Views
Last Modified: 2012-06-27
Hi!
I have written a Stored Procedure that does an update
of a table triggered by the user of my VB client.

Sometimes this SP encounters division by zero and gives
me the message:
Divide by zero occurred.

This is Ok by me and by Enterprise Manager. The SP executes
what it is supposed to do anyhow. But from VB (using RDO)
it fails because of this error.

So the question is:
What can I do in my SP to prevent it from failing when
it is called by the VB-client?
I have tried with setting some options but it didnt work.

Appreciate help!

                               // Kalle
0
Comment
Question by:Kalle 2
2 Comments
 
LVL 2

Accepted Solution

by:
Jim_SQL earned 300 total points
ID: 1090290
Hi,

Without your SP I can't say exactly, but hopefully you'll get the idea:

update SomeTable
set field_c = CASE field_b WHEN 0 THEN 0 ELSE field_a/field_b END


If this doesn't help, please post you query/SP.

(Hope this helped.)
Jim
0
 

Author Comment

by:Kalle 2
ID: 1090291
I got the idea, thanks!

                       // Kalle
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now