sql-serverdbccdata-paging

Null bitmap is set when there is no null columns


I am learning PAGE structure and currently I'm stuck at the NULL bitmaps.

create table dbo.ro
(
ID int not null,
Col1 varchar(8000) null,
Col2 varchar(8000) null
);
insert into dbo.ro(ID, Col1, Col2) values
(1,replicate('a',8000),replicate('b',8000));

So currently there is no NULL values, let's see DBCC info:

DBCC IND(test, 'ro', 1);
DBCC PAGE('test',1, 408,3);

enter image description here So I am interested in the following part 30000800 01000000 03005002

Why is it 50 and not 00? There is no NULL values in the record ...


Solution

  • The correct answer was in the comment and I upvoted it, but you still have a question so maybe I should explain you what does it mean.

    The bottom three bits are 0. The other bits should be ignored.

    If you expand 50 into a binary you've got 01010000. The only bits of interest are the bottom three bits, these correspond to 3,2,1 columns that are not null. The other bits should be ignored means the server knows the number of colums, it's 3, and it cares only about 3 bits in this mask. Other bits are not set, for that they should be ignored. They just contain a garbage.