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
 General SQL Server Forums
 Database Design and Application Architecture
 how do we store null in the database

Author  Topic 

nice123ej
Starting Member

48 Posts

Posted - 2007-07-12 : 08:52:15
Hi

I want to know how do we store null in the database

i know Null is unkown value

but it has to be something so the SQL server can know its null ( computer only knows 0s and 1s )

is it pointers and null does not have a pointer?
or do we store something physically?

an example : we have string(varchar) column that has this value in it "Joey Tribbiani" that means in the hard disk we will see 14 bytes "Joey Tribbiani" in there, if we changed the value to "Monika" the 14 bytes will be replaced by 5 bytes "Monika", if we changed to empty strike then we will have 0 bytes ""

now if changed it to become NULL what is going to happen to the hard disk, what is going to be in there physically??


may anyone help me in this?

many thanks

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-07-12 : 09:28:25
http://blogs.msdn.com/sqlserverstorageengine/archive/2006/06/29/650349.aspx

basicaly it's a 0 length space with the null bitmap set

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

nice123ej
Starting Member

48 Posts

Posted - 2008-06-25 : 23:54:20
does that mean, setting column as nullable will take more space than column does not allow null?!
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-06-26 : 04:20:04
this should clear things up:
http://weblogs.sqlteam.com/mladenp/archive/2007/09/06/How_does_SQL_Server_really_store_NULL-s.aspx


_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
Go to Top of Page
   

- Advertisement -