简体   繁体   中英

NVARCHAR(MAX) doesn't accommodate 50478 characters

I'm trying to store a string of 50478 characters length in a nvarchar(max) database field. According to this link , it tells that a nvarchar(max) field can store up to 1 billion characters, but when I tried to store just 50478 characters sql truncates them and doesn't store the full string.

How to solve such a problem?

Do you think that this is just a printing problem with sql server management studio?

You need to ensure that the data being inserted into the field is cast as nvarchar too otherwise you will not be able to achieve what you're looking for.

Take this as an example:

Create table #temp (this nvarchar(max))

insert into #temp values (REPLICATE(cast('a' as nvarchar(max)), 50478))

Select this, Len(this) from #temp

drop table #temp

Also can be viewed on SQL Fiddle here: http://sqlfiddle.com/#!6/551f7/2/0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM