0

Possible Duplicate:
Are there any disadvantages to always using nvarchar(MAX)?
varchar(max) everywhere?

Given the fact that varchar will always store the actual amount of characters it has, not its size (for example, a varchar(10) column containing "Hello" will only occupy 5 bytes), why not create all VARCHAR columns as varchar(max)?

Ok, there is the index issue where only columns with max of 900 bytes can be indexed, so why not create all the columns as varchar(900) or all the columns that are not due to be indexed as varchar(max) and the others as varchar(max)

Community
  • 1
  • 1
Diego
  • 34,802
  • 21
  • 91
  • 134
  • 1
    you mean, also the non-string columns? so for example to sum the integer columns you have to convert them? nah. – vulkanino Mar 02 '12 at 13:55
  • no no..all the string columns, the ones I would normally create as varchar(50) or varchar(100) – Diego Mar 02 '12 at 13:55
  • 1
    `varchar` has an overhead over `char`, to begin with. if you have a zipcode column that you know it will always store 5 chars, then why declare it `varchar(900)`? makes no sense. also, the size of the column is a source of **information** for both the readers and the db. – vulkanino Mar 02 '12 at 13:58
  • 1
    http://stackoverflow.com/questions/2091284/varcharmax-everywhere – Mikael Eriksson Mar 02 '12 at 14:03
  • 1
    http://stackoverflow.com/questions/858245/overhead-of-varcharmax-columns-with-small-data – Mikael Eriksson Mar 02 '12 at 14:03
  • 1
    http://stackoverflow.com/questions/2572649/are-there-disadvantages-to-using-varcharmax-in-a-table – Mikael Eriksson Mar 02 '12 at 14:05
  • I never mentioned CHAR @vulkanino – Diego Mar 02 '12 at 14:08

1 Answers1

0

I don't know all the details, but it has to do with how disk space is allocated. Is a link with some of the details.

http://msdn.microsoft.com/en-us/library/ms190969.aspx

cadrell0
  • 17,109
  • 5
  • 51
  • 69