Saturday, 4 February 2017

MSSQL - Fix Error - Divide by zero error encountered.


Watch this example on YouTube

To fix it replace

Declare @x As Integer = 1
Declare @y As Integer = 0
Select @x/@y

With

Declare @x As Integer = 1
Declare @y As Integer = 0
Select Case When @y != 0 Then Convert(Varchar,  @x/@y ) Else 'Cannot devide by 0' END

No comments:

Post a Comment