SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Get Your ANSI_NULLs Settings Consistent


Get Your ANSI_NULLs Settings Consistent

Author
Message
Bill Talada
Bill Talada
SSCarpal Tunnel
SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)

Group: General Forum Members
Points: 4669 Visits: 2227
Comments posted to this topic are about the item Get Your ANSI_NULLs Settings Consistent
Paul White
Paul White
SSC Guru
SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)

Group: General Forum Members
Points: 54824 Visits: 11392
An interesting article on an important subject. I would have rated it 5 stars instead of 4 if it had gone further in explaining what might need to be done to fix potential problems - sadly it is not as simple as replacing = NULL with IS NULL.

ANSI_NULLS OFF behaviour is decidedly odd, and often counter-intuitive, no wonder Microsoft are keen to stop supporting it. I have an example of this type of weirdness pending as a Question of the Day (QotD) so I'll just say that one example of weirdness involves IN and NOT IN...



Paul White
SQLPerformance.com
SQLblog.com
@SQL_Kiwi
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)

Group: General Forum Members
Points: 100312 Visits: 18616
Good article. I couldn't add anything more than what Paul has already indicated. Maybe a follow-up article on the same subject to go along with that QOD?;-)



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

Paul White
Paul White
SSC Guru
SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)

Group: General Forum Members
Points: 54824 Visits: 11392
CirquedeSQLeil (1/26/2010)
Good article. I couldn't add anything more than what Paul has already indicated. Maybe a follow-up article on the same subject to go along with that QOD?;-)

Good idea...



Paul White
SQLPerformance.com
SQLblog.com
@SQL_Kiwi
xdream
xdream
Grasshopper
Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)

Group: General Forum Members
Points: 18 Visits: 453
Nice article, just followed your steps on our databases. :-D

Though for general purpose, I'm missing some short explanations on ANSI settings and as you check them in step 2) and it's not only about ANSI NULL.

In step 4) I first was kind of surprised as the sql-statement will find other "= NULL"s, too (e.g. SET @Var = NULL). But it shows a starting point for checking your code automatically and fast.

Best regards
Bill Talada
Bill Talada
SSCarpal Tunnel
SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)

Group: General Forum Members
Points: 4669 Visits: 2227
I'm happy people are finding some value in the article; I had sent in a rough draft to see if it would be a topic of interest but they published it without asking me to tighten it up. My main purpose for writing the article was to show people how to be able to rip out all ANSI type statements from all their scripts and to never have to think again about any odd behavior of nulls on a per script basis.
andy.gray
andy.gray
SSC Rookie
SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)

Group: General Forum Members
Points: 33 Visits: 40
Most interesting but I have a little query.

Why is it necessary to have a function for comparing nullable ints but not for any other data types? Is there something specific about nullable ints?

Kind regards
Andy
Bill Talada
Bill Talada
SSCarpal Tunnel
SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)

Group: General Forum Members
Points: 4669 Visits: 2227
andy.gray (1/27/2010)
Most interesting but I have a little query.

Why is it necessary to have a function for comparing nullable ints but not for any other data types? Is there something specific about nullable ints?

Kind regards
Andy


The need for nullable compares is for all data types. I only have three in place for int, varchar, and datetime types so far for my needs. With a simple find/replace you can generate the others.
Richard Gibbins
Richard Gibbins
SSC Veteran
SSC Veteran (213 reputation)SSC Veteran (213 reputation)SSC Veteran (213 reputation)SSC Veteran (213 reputation)SSC Veteran (213 reputation)SSC Veteran (213 reputation)SSC Veteran (213 reputation)SSC Veteran (213 reputation)

Group: General Forum Members
Points: 213 Visits: 209
I'm probably stirring up a hornet's nest here but I have a problem with the way you are treating nulls. The whole point of null is that the value is undefined so comparing a value and saying they are equal if both are null is not valid. Two columns and/or variables are equal if and only if the values are defined and equal. Code should be aware of nulls and deal with them but not by equating two null values.

Richard
James Stephens
James Stephens
SSC-Enthusiastic
SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)

Group: General Forum Members
Points: 189 Visits: 210
I have been bitten by the IN/NOT IN null before...it's a tough one that had me scratching my head for an hour or so. That would make a good qod.
--Jim
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search