Null value

  • Hello kind people,

    Can someone please tell me if I have a table with fields which are "Allow Nulls" by it's definition, whether space is actually still allocated by the Server or not?

    We are trying to save some space on big tables and are considering turning off default values on some fields so that if they are not populated they hold a null value instead of .0000 ?

    Your input would be much appreciated.

    Ahsen

  • Hi Ahsen,

    quote:


    Can someone please tell me if I have a table with fields which are "Allow Nulls" by it's definition, whether space is actually still allocated by the Server or not?

    We are trying to save some space on big tables and are considering turning off default values on some fields so that if they are not populated they hold a null value instead of .0000 ?


    I think this is just the wrong way. In fact you waste space by allowing for NULL

    Maybe this one will help you

    http://www.sqlservercentral.com/forum/link.asp?TOPIC_ID=15988

    Frank

    Wenn Englisch zu schwierig ist?

    http://www.insidesql.de

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • All fixed length datatypes will take up the space if NULL or not. SO a CHAR(4) will take 4 bytes period, an int will take 4, datetime 8 and so on.

    However, non-fixed length datatypes will not. If a varchar(2000) field is created and it is NULL then it and the position pointer to it are not stored in the data. But if it is then add 2 extra bytes for the pointer but the field only takes up the number of bytes required to store the data that is entered. So 200 characters will take up 202 bytes total.

  • quote:


    But if it is then add 2 extra bytes for the pointer but the field only takes up the number of bytes required to store the data that is entered. So 200 characters will take up 202 bytes total.


    that's what I've said!

    Wasted space

    Frank

    http://www.insidesql.de

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply