Using NULLIF() To Prevent Divide-By-Zero Errors In SQL

In case you want to return zero, in case a zero devision would happen, you can use:

   SELECT ( 45 / NULLIF( 0, 0 ) ) AS value
For every divisor that is zero, you will get a zero in the result set

Comments

Popular posts from this blog

C# Crop white space from around the image

Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=xx.0.0.0, Culture=neutral, PublicKeyToken='xxx' or one of its dependencies.

The specified version string contains wildcards, which are not compatible with determinism.