Chad Callihan has a few methods for us to avoid dividing by zero:
In the real world, everyone knows that if you divide by zero a wormhole will open up and swallow the universe. In SQL Server, it’s not good, but it’s not nearly as dramatic. I encountered the following error this week and thought it would make a good topic:
Msg 8134, Level 16, State 1, Line 6
Divide by zero error encountered.There are multiple ways to handle this error message in SQL Server and some are better than others. Let’s take a look at a few.
Click through for those methods and try to keep this universe existent—it’s where I keep all my stuff.