Getting Started with Adobe After Effects - Part 6: Motion Blur
A collection of quick technology learning tips from what people around you learn every day

SQL Server - Trick to Supress Division by zero error

Feb 23 2012 12:00AM by Sandeep Prajapati   

Set ARITHABOBRT and ANSI_WARNINGS as OFF to handle division by Zero error

SET ARITHABORT OFF
SET ANSI_WARNINGS OFF
SELECT 1/0

This will not throw an error. Result will be NULL

Read More..   [32134 clicks]

Published under: SQL Server Tips ·  ·  ·  · 


Sandeep Prajapati
61 · 3% · 926
12
 
2
 
12
 
0
Incorrect
 
0
Interesting
 
0
Forgotten



Submit

2  Comments  

  • It's very useful, but - in my opinion - is somehow 'dirty'.

    You may, always, use NULLIF operator, ie:

    DECLARE @dividend INT ,@divisor INT
    SET @dividend = 1
    SET @divisor = 0
    
    SELECT @dividend / NULLIF(@divisor, 0)
    

    which will lead you to NULL when divisor is equal to 0.

    commented on Feb 23 2012 3:04AM
    Adam Tokarski
    58 · 3% · 1021
  • I agree. This is a very "dirty" way of doing things. I would not have this in any of my code - development, QA or production. Chances are that if the system does end up going down the path of a divide by zero error, there are some business issues up or down the chain which need to be corrected.

    commented on Feb 23 2012 10:57AM
    Nakul Vachhrajani
    4 · 36% · 11635

Your Comment


Sign Up or Login to post a comment.

"SQL Server - Trick to Supress Division by zero error" rated 5 out of 5 by 12 readers
SQL Server - Trick to Supress Division by zero error , 5.0 out of 5 based on 12 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]