Does the size used with NVARCHAR matter?

According to the 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.

So, only the actual length of the data entered matters when calculating the storage size.

The documentation doesn’t say why it’s there, but the length parameter is useful because it enforces simple limit constraints (for example, so someone can’t enter 2 GB of text as their “name”).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)