| |

VerySource

 Forgot password?
 Register
Search
Author: resource

How to shield from a division by zero error!

[Copy link]

0

Threads

11

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-1-27 12:27:01
| Show all posts
Add a sentence SET ARITHABORT OFF

SET ARITHABORT {ON | OFF}

Comment
If SET ARITHABORT is ON, these error conditions will cause the query or batch to terminate. If an error occurs within a transaction, the transaction is rolled back. If SET ARITHABORT is OFF and one of these errors occurs, a warning message is displayed and the result of the arithmetic operation is assigned a null value.



Note If neither SET ARITHABORT or SET ARITHIGNORE is set, Microsoft® SQL Server&# 8482; will return NULL and a warning message after executing the query.


If SET ARITHABORT is OFF and an INSERT, DELETE, or UPDATE statement encounters an arithmetic error (overflow, division by zero, or field error) during the evaluation of the expression, SQL Server inserts or updates the NULL value. If the target column is not nullable, the insert or update operation fails and the user receives an error message.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-1 03:00:01
| Show all posts
Judge first and execute
int intresult=(int)......(select sun(*) from .....)
if(intresult<1)
{
messagebox(".....");
}
else
{
Execute the statement you want
}
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-3 20:00:01
| Show all posts
Correct answer on the 7th floor. Thank you
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-5 15:30:01
| Show all posts
Can be solved with case
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list