C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




TO avoid divide by zero problem in sql server


Posted Date: 27 Dec 2007    Resource Type: Articles    Category: Databases

Posted By: amisha       Member Level: Gold
Rating:     Points: 10





Many times while executing querry suppose
 select 100/0 

it will encounter error as ..
Divide by zero error encountered.

So,as this is a simple example we can find out the error. But sometimes in long procedure it would be difficult.
SO it this case you can get the value as null insted of error by including these two steps

1.> SET ARITHABORT OFF
Description :
This is used to handle divide by zero problem .If you you will make it off .

2> SET ANSI_WARNINGS ON
ANSI_WARNINGS should be set to ON for executing distributed queries.

iF SET ARITHABORT is OFF and SET ANSI_WARNINGS is ON, SQL Server still returns an error message when encountering divide-by-zero or overflow errors.
sO YOU HAVE TO MAKE BOTH OF THEM AS OFF.........................


SO,NOW IF WE WILL TRY

SET ARITHABORT OFF SET ANSI_WARNINGS OFF
SELECT 100/0



It will return result as NULL



Hope this article will give a basic idea..







Responses

Author: Vadivel Mohanakrishnan    30 Dec 2007Member Level: Diamond   Points : 0
http://vadivel.blogspot.com/2007/04/workarond-for-divide-by-zero-error.html


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Divide by zero  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: SQLCMD -- Part III
Previous Resource: Exception Handling in SQL Server with .Net
Return to Discussion Resource Index
Post New Resource
Category: Databases


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use