Skip to content
Advertisement

Converting ntext to nvcharmax(max) – Getting around size limitation

I’m trying to change an existing SQL NText column to nvcharmax(max), and encountering an error on the size limit. There’s a large amount of existing data, some of which is more than the 8k limit, I believe.

We’re looking to convert this, so that the field is searchable in LINQ.

The 2x SQL statements I’ve tried are:

And the error I get is:

This is using SQL Server 2008.

Any help appreciated, Thanks.


Update / Solution:

The marked answer below is correct, and SQL 2008 can change the column to the correct data type in my situation, and there are no dramas with the LINQ-utilising application we use on top of it:

I’ve also been advised to follow it up with:

Which completes the conversion by moving the data from the lob structure to the table (if the length in less than 8k), which improves performance / keeps things proper.

Advertisement

Answer

That is most likely because the column dataNVarChar is not defined as NVARCHAR(max) To convert a column from NTEXT to NVARCHAR(MAX), use this

It will perform the conversion of the data in the column for you at the same time

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement