2

On SQL Server 2008 R2 (64 bit) what is the max size of a varchar(max)?

I know that after 8K it goes to an overflow page, but I don't know how many chars I can put in over all.

Vaccano
  • 78,325
  • 149
  • 468
  • 850
  • 3
    Did you look on [MSDN](http://msdn.microsoft.com/en-us/library/ms176089.aspx)? 2^31 -1 *bytes" – gbn Oct 17 '11 at 16:29
  • @gbn - I did look at MSDN. I think my confusion came from not being sure that one "char" = one byte. – Vaccano Oct 17 '11 at 16:31
  • nvarchar(max): http://msdn.microsoft.com/en-us/library/ms186939.aspx No different tom, say char(100) vs nchar(100) = 100 bytes vs 200 bytes – gbn Oct 17 '11 at 16:32
  • 2
    `varchar(max)` [Variables seem to allow longer though](http://stackoverflow.com/q/7611394/73226) – Martin Smith Oct 17 '11 at 16:35

2 Answers2

4

the MAX types can accomodate 2GB of data. See MSDN.

DeCaf
  • 6,026
  • 1
  • 29
  • 51
0

Validating from .Net prior to calling SQL it will be int.MaxValue

Console.WriteLine(int.MaxValue);
> 2147483647
dynamiclynk
  • 2,275
  • 27
  • 31