I want to store a text to SQL Server. My text has very different lengths (1-10000 characters length). I want to store text with minimum size tenure in database.
My question: what do I have to select as the column type?
And when we select a type for a column like a varchar(100)
when we add row with value null for the column, does the database size increase?
For example, I have table like this:
id txt(Varchar(100))
--- -----
1 some text
2 null
when I add a row with a null value for txt column, does the database size increase?
varchar
is the only option here. it is stored by database efficiently and takes as much as space needed (+overhead).
By that mean, if you'r data is 100 character it will use less storage than when your data is 1000 character.
This is a good book to read about it: "Microsoft SQL Server 2008 Internals"