nvarchar(max) vs nvarchar(N)
MS SQL Server offers several data types for storing strings.
The most popular are nvarchar(N) (1 ≤ N ≤ 4000) and nvarchar(max), which allow storing Unicode-encoded string data.
Application developers often transfer their experience with the string type from programming languages like C# or Java to databases and automatically choose nvarchar(max), which can store strings up to 2GB.
However, databases store and process data in fundamentally different ways.
In this article, I will explain and demonstrate the consequences of unjustified use of the nvarchar(max) type.
Csharp (22)
.net (20)
performance (9)
benchmark (9)
LINQ (8)
collections (4)
.net6 (3)
.net8 (3)
.net48 (3)
.netcore31 (3)
MSSQL (3)
.net10 (2)
list (2)
.net9 (2)
string (2)
TSQL (2)
patterns (2)
stackoverflow (2)
HashSet (1)
dapper (1)
sql (1)
regex (1)
.net5 (1)
optimization (1)
roslyn (1)
analyzer (1)
NDepend (1)
asp.net (1)
.net471 (1)
specification (1)
repository (1)
EntityFramework (1)
xml (1)
soap (1)
CancellationToken (1)
Timer (1)
debug (1)
properties (1)
IEnumerable (1)
foreach (1)
retry (1)
circuit breaker (1)