Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12345»»»

ANSI_NULLS Expand / Collapse
Author
Message
Posted Tuesday, April 6, 2010 9:09 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Saturday, August 30, 2014 4:20 PM
Points: 11,194, Visits: 11,142
Comments posted to this topic are about the item ANSI_NULLS



Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #898093
Posted Tuesday, April 6, 2010 10:03 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 6:02 PM
Points: 21,657, Visits: 15,326
Nice question Paul.



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


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #898118
Posted Tuesday, April 6, 2010 10:10 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Saturday, August 30, 2014 4:20 PM
Points: 11,194, Visits: 11,142
CirquedeSQLeil (4/6/2010)
Nice question Paul.

1. Did you get it right?
2. Are you scared by the behaviour ANSI_NULLS OFF?




Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #898123
Posted Tuesday, April 6, 2010 10:13 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 6:02 PM
Points: 21,657, Visits: 15,326
Paul White NZ (4/6/2010)
CirquedeSQLeil (4/6/2010)
Nice question Paul.

1. Did you get it right?
2. Are you scared by the behaviour ANSI_NULLS OFF?


Yes I got it correct.
I thought you explained things nicely.

And yes, by having Ansi_Nulls Off, I can see there being complications. I will have to verify this setting on my servers.




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


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #898126
Posted Tuesday, April 6, 2010 10:33 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Saturday, August 30, 2014 4:20 PM
Points: 11,194, Visits: 11,142
CirquedeSQLeil (4/6/2010)
And yes, by having Ansi_Nulls Off, I can see there being complications. I will have to verify this setting on my servers.

SELECT  object_type = OBJ.type_desc,
[schema_name] = SCHEMA_NAME(OBJ.[schema_id]),
[object_name] = OBJ.name,
SM.[definition]
FROM sys.objects OBJ
JOIN sys.sql_modules SM
ON SM.[object_id] = OBJ.[object_id]
WHERE OBJ.type_desc IN
(
N'SQL_STORED_PROCEDURE',
N'SQL_SCALAR_FUNCTION',
N'SQL_INLINE_TABLE_VALUED_FUNCTION',
N'SQL_TABLE_VALUED_FUNCTION',
N'SQL_TRIGGER',
N'VIEW'
)
AND SM.uses_ansi_nulls = 0
AND OBJ.is_ms_shipped = 0
ORDER BY
object_type,
[schema_name],
[object_name];





Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #898136
Posted Tuesday, April 6, 2010 11:13 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 12:04 PM
Points: 6,594, Visits: 8,882
I agree... Good question. Made me sit back and think about this a bit.

Wayne
Microsoft Certified Master: SQL Server 2008
If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
Links: For better assistance in answering your questions, How to ask a question, Performance Problems, Common date/time routines,
CROSS-TABS and PIVOT tables Part 1 & Part 2, Using APPLY Part 1 & Part 2, Splitting Delimited Strings
Post #898156
Posted Tuesday, April 6, 2010 11:54 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, June 30, 2014 2:51 AM
Points: 2,017, Visits: 369
Thanks for the question, Paul. Luckily, I have set
ANSI_NULLS ON

on my servers..
Post #898178
Posted Wednesday, April 7, 2010 12:28 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Saturday, August 30, 2014 4:20 PM
Points: 11,194, Visits: 11,142
ziangij (4/6/2010)
Thanks for the question, Paul. Luckily, I have set
ANSI_NULLS ON

on my servers..

Good stuff.

If you would like to check that no-one else has manually created a procedure, function, trigger, or view and overridden your default settings at the session level, run the script I posted before - just to check




Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #898192
Posted Wednesday, April 7, 2010 2:05 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Friday, May 9, 2014 12:47 AM
Points: 3,448, Visits: 4,407
Nice question.
Maybe I read it too fast: "Select all...", I selected "ABCD", then pressed the "Submit" button. Oops, there was "...that apply" part

It's interesting to explore the execution plans.
The condition "= NULL" is replaced with the condition "IS NULL". Execution plans "A" and "C" both have the node "Table Scan(OBJECT: (@T), WHERE: ([A] IS NULL))".
Execution plan "B" has the only node "Constant Scan", which means SQL Server understands (at compile time!) that there will be no output rows.
Execution plan "D" has the node "Table Scan(OBJECT: (@T), WHERE: ([A]=[A]))". This clarifies why "if both sides of the comparison are columns ... the setting [SET ANSI_NULLS] does not affect the comparison."
Post #898255
Posted Wednesday, April 7, 2010 2:19 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Friday, August 29, 2014 10:20 AM
Points: 1,740, Visits: 6,366
Is there any situation where setting ansi_nulls off is a good idea?
Post #898268
« Prev Topic | Next Topic »

Add to briefcase 12345»»»

Permissions Expand / Collapse