SqlShare.com Logo
 
Skip Navigation Links
Home
Video List
Events
Classes
About Us
Login / Register
Subscribe RSS Feed 

Idera SQL Check

Handling Division by Zero with NULLIF

Dividing by zero is always a problem when dealing with numeric columns in SQL Server. This video shows you a different way to handle division by zero errors using the NULLIF statement.

Duration:
3 mins 28 secs
Skill Level:
100
Rating:
4.49 out of 5
Publish Date:
November 03, 2008
Handling Division by Zero with NULLIF You must be logged in to view this video.  
Bookmark and Share
 
1=Poor, 3=Good, 5=Excellent

About the Author

Image of Plamen Ratchev
Plamen Ratchev has over two decades experience in the software architecture and development field. He has enjoyed building solutions for UNIX, DOS and Windows platforms, with main focus on SQL Server since version 4.21. Plamen is founder of Tangra, specializing in relational database applications analysis, implementation, and tuning. His particular interest is in design patterns, performance a...

References



Comments
1A210B2C2C on 4/13/2009
Very useful!

Mahesh Kansara on 4/13/2009
instead of COALESCE, can we use isnull?

This was very good and exposed me to a couple of new verbs.

Carla Wilson on 4/13/2009
Good examples. Thanks.

Very clear and concice. The NULLIF T-SQL fcn explained well. The breakdown of the COALESCE function could have been better

SUBRATA SARKAR on 4/13/2009
simple

Paul Murray on 4/13/2009
What is the difference in using NULLIF instead of ISNULL?

Holck on 4/14/2009
I can use this today! How handy!

Holck on 4/14/2009
Mahesh, I think they are equivalent in this case. Coalesce would shine where you had multiple values and wanted SQL to return the first null instead of only one value to return if null. But if it were me, I'd try both and compare the performance, as that might be the difference! Paul, I think the difference is that NULLIF returns a null when a condition is met and ISNULL is used when you want to return something else instead of the null.

Holck on 4/14/2009
Paul, I think the difference is that NULLIF returns a null when a condition is met and ISNULL is used when you want to return something else instead of the null. (Sorry, repeating for clarity)

Virendra on 4/14/2009
Great.

Plamen Ratchev on 4/14/2009
Mahesh, as noted by Holck you can use ISNULL instead of COALESCE. There are some differences between the functions but the logic here will not be affected. COALESCE is in ANSI SQL and this is why I prefer to use it.

I learn something today.

skaykov on 4/19/2009
VEry usefull and interesting

Dan Asbury on 4/24/2009
clever, usefull video

Mikael Jansson on 4/24/2009
short and nice describing video that gave me the info I needed within minutes

Carl Draves on 5/11/2009
Good to know.

Kristeen Sellers on 7/13/2009
Very helpful. Answered a problem I was having at this very moment.

sreekanth on 8/13/2009
Simple to think But had No idea till Now..

Tonci on 6/4/2010
excellent alternative to using case!!

SAy Soukamneuth on 1/28/2011
Good

Brenda Burton on 9/7/2011
Very helpful!

Amar0009 on 9/7/2011
Good learning for us beginners... Thanks.

Kasey Wheeler on 9/7/2011
Great tip.

Tim on 9/7/2011
Excellent video. Useful and to the point.

Steve Harris on 9/7/2011
could you also have used the ISNULL function instead of the COALESCE

Matt Dobson on 9/7/2011
useful tip

Mark Horninger on 9/7/2011
Good info! I would like the see the difference in the execution plan between nullif and case... would the performance be similar?

Andy on 9/7/2011
Great video. This is exactly the kind of thing I came here for :)

Nate on 9/7/2011
I've always wanted to know how to use NULLIF()...now I know. Thanks Great Video!!!

Kristeen Sellers on 9/7/2011
Very interesting approach.

A4A72D151B on 9/7/2011
this is a common error I experience. thanks!

ML Stephens on 9/7/2011
coalesce good thought

Matthew Fiedler on 9/7/2011
Excellent video presentation. Easy to follow and great reduction in coding.

Farid on 9/7/2011
no need to see how to create a table and insert rows

erick on 9/7/2011
Nice, I like it!

1F05990EE7 on 9/7/2011
It was short and nice video.

Ryan Luu on 9/7/2011
good dude.

Paul Jemiolo on 9/7/2011
Great content! ;)

FELIX on 9/7/2011
Good video!

Sumitra on 9/7/2011
Excellent tutorial

Yelena on 9/8/2011
Very interesting and usefull to know. Thanks!!!

Ashfaque on 9/8/2011
thanks it great

Max Turavani on 9/9/2011
Nice.Beats the CASE statement anyday.

B on 9/13/2011
good info - accent hard to understand tho

Sunil on 9/19/2011
I learnt new thing today COALESCE and NULLIF. Thank you very much. It was brief and clear. It suits my style of studying!!!!!

7F718A6344 on 9/21/2011
What a great video with all those examples!

Eric on 9/23/2011
Very useful methods to write compact, efficient statments.

mindy on 11/8/2011
Good job explaining. Nice and slow and thorough!

Karen on 11/30/2011
just what I was looking for!

Frank on 1/2/2012
excxellent

Maurice Ivory on 2/16/2012
It was cool but my video skipped and I misse important information.



Must Be Logged In
 

How Do I Become a Video Author? |  Newsletter History

Copyright © Fourdeuce, Inc., 2005-2009. All Rights Reserved | Privacy Policy | Terms & Conditions