best way to store very variable length string in sql table

  • Thread starter Thread starter Steve Richter
  • Start date Start date
S

Steve Richter

The strings I want to store in an SQL table will 99% of the time be
short, 128 characters or less. But they could be much longer ( the
RawUrl from the asp.net Request object ).

What is the best way to declare such a string?

Will I be wasting a lot of space if I declare the column as
VarChar(9999)? Or do strings in SQL just use the actual length of the
string?

thanks,

-Steve
 
I believe varchar columns will only take up the space of the characters
actually being stored in them.

Columns declared as 'char', are the ones that are always a fixed length
regardless of the values being stored.
 
Marina said:
I believe varchar columns will only take up the space of the characters
actually being stored in them.

Columns declared as 'char', are the ones that are always a fixed length
regardless of the values being stored.

ok, thank you Marina.

-Steve
 
Hi Marina,

Marina said:
I believe varchar columns will only take up the space of the characters
actually being stored in them.

To be more precise, it stores actual characters plus some metadata (few
bytes) :-)
Columns declared as 'char', are the ones that are always a fixed length
regardless of the values being stored.

Right.
 
Back
Top