Search code examples
sql-serversqldatatypes

Is Varchar(Max) take much space than Varchar(N) if text length is fixed?


i am working on existing software(SQL,C#) for increase its efficiency.in this project every where varchar(max) is used where string required.I want to convert varchar(Max) into varchar(N).for this purpose i read many article which compares varchar(max) Vs varchar(N)-it is clear that response time of varchar(N) is grater than Varchar(Max).But my question about storage comparison Varchar(Max) Vs Varchar(N)-e.g. if i insert "Hello", is storage same for both datatypes varchar(Max) and varchar(100)? if not then how much difference in both cases?


Solution

  • Varchar(MAX) & Varchar(n) reserve fix space for same text store in Column. I have two table tblMaxData & tblNData and both table have single column with VARCGAR(MAX) & VARCHAR(N). Column have 'Hello' Value in Both Table. After then i was checked space , both column has same occupied Space. enter image description here

    enter image description here