Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 BIT Data Type Storage

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-12-05 : 08:16:47
jmhmaine writes "If SQL Server is storing the BIT data type as one bit, how does it store the absence of data, e.g. null values?

Since a bit can only have two values, True/False or 0/1 how do does the Server track that bit is Null?"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-12-05 : 08:29:38
If the bit column is defined as Null, SQL Server will store it as Null if no value is supplied to it

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2005-12-05 : 08:38:30
quote:
Originally posted by AskSQLTeam

jmhmaine writes "If SQL Server is storing the BIT data type as one bit, how does it store the absence of data, e.g. null values?

Since a bit can only have two values, True/False or 0/1 how do does the Server track that bit is Null?"


The information about whether a column in a row contains NULL is stored in the row's NULL bitmap. At least, that's what Kalen Delaney says in Inside SQL Server 2000. And I believe her!

Looking at this page http://msdn2.microsoft.com/en-us/library/ms178085.aspx it seems this is still the case in SQL Server 2005.
Go to Top of Page

paulrandal
Yak with Vast SQL Skills

899 Posts

Posted - 2005-12-05 : 12:00:04
One slight twist for SS2005, all columns have a bit in the NULL bitmap, regardless of whether they're NULLable or not, rathert han just the NULLable ones (SS2000). This makes a lot of things easier at negligible extra storage cost.

Paul Randal
Lead Program Manager, Microsoft SQL Server Storage Engine
(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.)
Go to Top of Page
   

- Advertisement -