1

What I understand: If I define a column with Varchar(100) and then store only 40 bytes then SQL will allot only 40 bytes for that cell. What I want to know: Now, if I define all my cells as Varchar(8000) then what is the problem? Why should I even use Varchar(100) or Varchar(anything else except 8000)?

Also, Why not just use Varchar(max) instead of varchar(8000) as I understand 8000 is the max value.

Alok Singh
  • 174
  • 3
  • 15
  • 4
    8000 is not the max value. With MAX when 8000 is reached it is stored in an overflow. – Igor Jul 29 '16 at 16:57
  • 1
    @Vercelli I got exactly what I wanted. Igor - That's helps a lot too. – Alok Singh Jul 29 '16 at 17:00
  • Hi Which SQl Server are you using. – Rohit Gupta Jul 29 '16 at 17:33
  • 4
    There are many, many reasons to size your columns correctly instead of just blanket 8000 or max everywhere. For example, memory grants are calculated assuming all variable-length columns are half full. Should everyone on my block buy a dump truck because they would fill it once every 5 years? – Aaron Bertrand Jul 29 '16 at 17:34
  • 1
    Also look at this answer and links as well:http://dba.stackexchange.com/questions/140790/using-max-text-or-more-specific-smaller-type – TheGameiswar Jul 29 '16 at 17:41
  • Go have a look at [What's the Point of Using VARCHAR(n) anymore?](https://www.simple-talk.com/sql/database-administration/whats-the-point-of-using-varchar(n)-anymore/) - makes a lot of good points *why* you shouldn't just use `varchar(max)` everywhere.... – marc_s Jul 29 '16 at 18:16
  • look at the link http://stackoverflow.com/q/28980502/1805776 – vicky Oct 18 '16 at 09:42
  • varchar(8000) stores a maximum of 8000 characters. varchar(max) stores a maximum of 2 147 483 647 characters. refer this url http://www.interviewquestionspdf.com/2015/10/sql-server-storagesizecapacity-related.html – Laxmi Oct 19 '16 at 05:00

0 Answers0