How is data physically saved?

  • Suppose I have a table with 3 fields:

    Field1 DateTime

    Field2 Char(10)

    Field3 numeric(16,2)

    Field1 has value 20080610, Field2 has no value, field3 has value 21625,25. When this data is saved, is it saved in this order, like the tabledefinition? Will there be a gap of 10 bytes between Field1 and field2 or not?

    If Field2 has the value 'abc', will there be 3 bytes saved, or still 10 bytes?

    Greetz,
    Hans Brouwer

  • You should read through the physical storage architecture sections or BOL or pick up a copy of Inside SQL Server.

    If you have CHAR, then the space is saved in the table. It's a fixed width. Variable length columns store an offset and the data is stored at the end of the row, so space is saved if you store no data in a variable length data type.

Viewing 2 posts - 1 through 2 (of 2 total)

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