I have declared a column of type NVARCHAR(MAX)
in SQL Server 2008, what would be its exact maximum characters having the MAX as the length?
This question is related to
sql-server
sql-server-2008
sql-server-2005
From MSDN Documentation
nvarchar [ ( n | max ) ]
Variable-length Unicode string data. n defines the string length and can be a value from 1 through 4,000. max indicates that the maximum storage size is 2^31-1 bytes (2 GB). The storage size, in bytes, is two times the actual length of data entered + 2 bytes
I think actually nvarchar(MAX)
can store approximately 1070000000 chars.
By default, nvarchar(MAX) values are stored exactly the same as nvarchar(4000) values would be, unless the actual length exceed 4000 characters; in that case, the in-row data is replaced by a pointer to one or more seperate pages where the data is stored.
If you anticipate data possibly exceeding 4000 character, nvarchar(MAX) is definitely the recommended choice.
Source: Stackoverflow.com