In SQL Server, nvarchar
takes twice the space of varchar
, and its pre-page-pointer limit is 4000 compared to varchar
's 8000.
So, why does the following like
comparison give a String or binary data would be truncated.
error...
select 1 where '' like cast(replicate('x', 4001) as nvarchar(max))
...while casting as a massively larger varchar
does not?
select 1 where '' like cast(replicate('x', 123456) as varchar(max))
In fact, why does the top live give a truncation error at all when it's clearly declared as nvarchar(max)
which has a size limit of about 2GB?