Tuesday, 17 July 2018

MSSQL - FIx Error - Divide by zero error encountered


Watch this example on YouTube


Replace

Declare @Number1 int = 1
Declare @Number2 int = 0
Select @Number1 / @Number2

with

Declare @Number1 int = 1
Declare @Number2 int = 0
Select @Number1 / nullif( @Number2, 0)

No comments:

Post a Comment