【发布时间】:2011-06-10 03:46:09
【问题描述】:
我正在尝试将现有 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),从而提高性能/保持正确。
【问题讨论】: