Divide by zero error encountered in SQL Server


       Msg 8134, Level 16, State 1, Line 1
      Divide by zero error encountered.



        select col1/col2 from tbl
        select 12/0


                        if col2 field value as Zero then You get    Divide by zero error encountered. Error on Your SP.
  You Can USE NULLIF  SQL Function to Solve this Problem.

           select col1/ NULLIF(col2,0)


Comments

Popular posts from this blog

Unable to perform operation on the item is locked in workspace

Maximum Stored Procedure Function Trigger or View Nesting Level Exceeded (limit 32) in SQL Server

Insecure cookie setting: missing Secure flag