我正在尝试将现有的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
Run Code Online (Sandbox Code Playgroud)
而我得到的错误是:
Cannot create a row of size 8086 which is greater than the allowable maximum row size of 8060.
Run Code Online (Sandbox Code Playgroud)
这是使用SQL Server 2008.
任何帮助表示感谢,谢谢.
下面标记的答案是正确的,SQL 2008可以在我的情况下将列更改为正确的数据类型,并且我们在其上使用的LINQ利用应用程序没有戏剧性:
alter table [TBL] alter column [COL] nvarchar(max)
Run Code Online (Sandbox Code Playgroud)
我也被建议跟进:
update [TBL] set [COL] = [COL]
Run Code Online (Sandbox Code Playgroud)
通过将数据从lob结构移动到表(如果长度小于8k)来完成转换,从而提高性能/保持正常.
Ric*_*iwi 17
这很可能是因为列dataNVarChar未定义为NVARCHAR(max)要将列从NTEXT转换为NVARCHAR(MAX),请使用此
alter table TBL alter column COL nvarchar(max)
Run Code Online (Sandbox Code Playgroud)
它将同时为您执行列中数据的转换