Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Databases Programming Interviews:BtrieveClipperData ModelingData StructuresDatabase AdministrationDatabase Administrator (DBA)Database AnalystDatabase DeveloperDB DevelopmentEDI/Data Integration ExpertFirebirdHierarchicalIBM DB2InformixJava DatabaseMariaDBMicrosoft Access DeveloperMongoDBMS SQL ServerMySQL ProgrammingNetworkNoSQLObject RelationalPostgrePostgreSQLProgressRDBMSRelationalSQLSQL AdministratorSQL and PL/SQLSQL Notification ServicesSQL server 2008SSRSStored ProcedureSybaseTeradata
Copyright © 2018. All Rights Reserved
MS SQL Server Interview Question:
What Happens If NULL Values Are Involved in Boolean Operations?
Submitted by: AdministratorIf NULL values are involved in Boolean operations, the result will vary depending on the operator type. For AND operator, FALSE takes precedence over NULL. The result can be summarized in a table below:
<pre>AND TRUE FALSE NULL
TRUE true false null
FALSE false false false
NULL null false null</pre>
For OR operator, TRUE takes precedence over NULL. The result can be summarized in a table below:
<pre>OR TRUE FALSE NULL
TRUE true true true
FALSE true false null
NULL true null null</pre>
The tutorial script below shows you that NULL AND FALSE returns FALSE:
IF 0=NULL AND 0=1 PRINT 'NULL AND FALSE returns TRUE'
ELSE PRINT 'NULL AND FALSE does not returns TRUE'
GO
NULL AND FALSE does not returns TRUE
IF NOT (0=NULL AND 0=1)
PRINT 'NULL AND FALSE returns FALSE'
ELSE PRINT 'NULL AND FALSE does not returns FALSE'
GO
NULL AND FALSE returns FALSE
Submitted by: Administrator
<pre>AND TRUE FALSE NULL
TRUE true false null
FALSE false false false
NULL null false null</pre>
For OR operator, TRUE takes precedence over NULL. The result can be summarized in a table below:
<pre>OR TRUE FALSE NULL
TRUE true true true
FALSE true false null
NULL true null null</pre>
The tutorial script below shows you that NULL AND FALSE returns FALSE:
IF 0=NULL AND 0=1 PRINT 'NULL AND FALSE returns TRUE'
ELSE PRINT 'NULL AND FALSE does not returns TRUE'
GO
NULL AND FALSE does not returns TRUE
IF NOT (0=NULL AND 0=1)
PRINT 'NULL AND FALSE returns FALSE'
ELSE PRINT 'NULL AND FALSE does not returns FALSE'
GO
NULL AND FALSE returns FALSE
Submitted by: Administrator
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.