patternsqlModerate
Are the limits of varchar(8000) and nvarchar(4000) because of the sql server page size (8KB=8192 Bytes)?
Viewed 0 times
8000thenvarcharserveraresqlsizevarchar4000limits
Problem
I know that varchar(max) and nvarchar(max) allow upto 2GB of data to be held, but this is not relevant to this question.
A page is 8KB = 8192 Bytes
In varchar, 1 character is 1 byte. Whereas in nvarchar, 1 character is 2 bytes.
varchar is allowed to have 8000 characters (8000 Bytes). Whereas nvarchar is allowed to have 4000 characters (8000 Bytes).
Is this because the page size is 8192 Bytes?
A page is 8KB = 8192 Bytes
In varchar, 1 character is 1 byte. Whereas in nvarchar, 1 character is 2 bytes.
varchar is allowed to have 8000 characters (8000 Bytes). Whereas nvarchar is allowed to have 4000 characters (8000 Bytes).
Is this because the page size is 8192 Bytes?
Solution
Is this because the page size is 8192 Bytes?
Yes. In SQL Server version 7 the 8K page was introduced and varchar(n) max length went from 255 to 8000.
The page size before version 7 was 2K, so allowing a varchar to take up most of a page was new too.
Yes. In SQL Server version 7 the 8K page was introduced and varchar(n) max length went from 255 to 8000.
The page size before version 7 was 2K, so allowing a varchar to take up most of a page was new too.
Context
StackExchange Database Administrators Q#307776, answer score: 15
Revisions (0)
No revisions yet.