Forum Discussion
tuspatil
Oct 08, 2025Copper Contributor
Why is SQL Server only storing 4000 characters in an NVARCHAR(MAX) column?
Hi Guys, I'm trying to insert a string with 10,000 plain characters (just repeated 'A's) into a column defined as NVARCHAR(MAX) in SQL Server. But LEN(Content) always returns 4000, not 10,000. I...
- Oct 08, 2025
Try to cast the N'A'. The next example shows the differences:
declare @LongText1 nvarchar(max) declare @LongText2 nvarchar(max) set @LongText1 = replicate(N'A', 10000) set @LongText2 = replicate(cast(N'A' as nvarchar(max)), 10000) select len(@LongText1), len(@LongText2) -- returns 4000 and 10000
Viorel
Oct 08, 2025Copper Contributor
Try to cast the N'A'. The next example shows the differences:
declare @LongText1 nvarchar(max)
declare @LongText2 nvarchar(max)
set @LongText1 = replicate(N'A', 10000)
set @LongText2 = replicate(cast(N'A' as nvarchar(max)), 10000)
select len(@LongText1), len(@LongText2) -- returns 4000 and 10000