Presentation is loading. Please wait.

Presentation is loading. Please wait.

NULLs and Other SQL Gotchas

Similar presentations


Presentation on theme: "NULLs and Other SQL Gotchas"— Presentation transcript:

1 NULLs and Other SQL Gotchas
Wendy Pastrick

2 About DBA since 2000 Salesforce Performance DBA
Data Platform MVP since 2013 PASS Board of Directors – Educational Content

3 Data Data Data Null ANSI settings Unknown NULL = NULL
Validation ISNULL = NULL

4 No Data? Empty vs Null Datatype matters! Integer String Date
converts to 0 String Empty (‘’) Date :00:00.000

5 Fallout Your SQL code that would otherwise expect to work like the IS NULL or IS NOT NULL checks won’t work anymore In case you were doing this for a number column, the aggregate functions like AVG() which otherwise would be ignoring the Null value will now count the record

6 Fallout…more The SQL code which uses functions like ISNULL(), COALESCE() etc. will not function as expected since these fields will not have a Null value. The sorts won’t work as expected since Null and the empty string (and the subsequent default value that actually gets inserted) are not the same thing.

7 ….and even More If you have this column as part of the foreign key, you will get an error at the time of the insert itself since instead of a Null value, the code will try to insert another default value in and it will violate the FK constraint. Any concatenation operations or MAX(), MIN() functions can lead to un-desired results.

8 Scalar Functions Performance killer RBAR
Only returns a single value per input Table Valued Functions preferable, but still not awesome.

9 Date and Time Discussion

10 Thank You! Wendy.Pastrick@gmail.com Resources
and-why-will-i-be-glad-when-it-finally-goes-away/ data-type/ string/ kick-using-the-wrong-data-type.aspx


Download ppt "NULLs and Other SQL Gotchas"

Similar presentations


Ads by Google