我正在尝试将现有的 SQL NText列更改为nvcharmax(max),并遇到大小限制错误。我相信有大量的现有数据,其中一些超过了 8k 的限制。
我们正在寻找转换它,以便在 LINQ 中可以搜索该字段。
我尝试过的 2x SQL 语句是:
update Table
set dataNVarChar = convert(nvarchar(max), dataNtext)
where dataNtext is not null
update Table
set dataNVarChar = cast(dataNtext as nvarchar(max))
where dataNtext is not null
我得到的错误是:
Cannot create a row of size 8086 which is greater than the allowable maximum row size of 8060.
这是使用 SQL Server 2008。
任何帮助表示赞赏,谢谢。
更新/解决方案:
下面标记的答案是正确的,SQL 2008 可以在我的情况下将列更改为正确的数据类型,并且我们在其上使用的 LINQ 应用程序没有任何戏剧性:
alter table [TBL] alter column [COL] nvarchar(max)
我还被建议跟进:
update [TBL] set [COL] = [COL]
它通过将数据从 lob 结构移动到表(如果长度小于 8k)来完成转换,从而提高性能/保持正确。