SQL Divide by Zero

by ebarcza 9/23/2009 7:40:00 AM

T-SQL Avoid Divide by Zero errors

Sometimes you can't help it -  zeros appear in the denominator of formulas in a stored procedure or function, take care of them by using the nullif function to null them out NULLIF ( expression1 , expression2 ) 

Returns a null if Expression1 and Expression 2 are equal
EX: nullif(@MyValue, 0)

Tags:

SQL SERVER

Comments

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

About the author

Name of author Author name
Something about me and what I do.

E-mail me Send mail

Calendar

<<  November 2020  >>
MoTuWeThFrSaSu
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

View posts in large calendar

Recent comments

Tags

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2020

Sign in