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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Divide by Zero Error Counter
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

27 Posts

Posted - 07/14/2013 :  22:33:07  Show Profile  Reply with Quote
How to solve divide by zero error when I need to display
all records in query?
CodeItem QtyOK Target
A 50 0
B 100 50
C 0 50

The query should resulting records like this :
CodeItem QtyOk Target Percent(QtyOk/Target)
A 50 0 0
B 100 50 200
C 0 50 0

Thank you.

Aged Yak Warrior

549 Posts

Posted - 07/14/2013 :  22:56:55  Show Profile  Reply with Quote

QtyOk / NULLIF(Target,0)
Go to Top of Page

Premature Yak Congratulator

22864 Posts

Posted - 07/23/2013 :  05:08:00  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
or in General

QtyOk / case when Target=0 then NULL else Target end


Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000