【问题标题】:Changing collation on a column with multipage rows更改具有多页行的列的排序规则
【发布时间】:2013-01-10 21:41:53
【问题描述】:

我们正在更改数据库的排序规则。

我们遇到了一个问题,当我尝试更改其中一列(数据类型为 varchar(max))时,我收到以下错误:

Cannot create a row of size 8083 which is greater than the allowable maximum row size of 8060.

如果我检查最大帖子的大小。

select top 1 LEN(Document) as l1,* from GroupDocument where LEN(document) > 8000 order by LEN(document) desc

我得到的尺寸是 39431,大约 10 页。

我认为这是我无法更改排序规则的问题。我之前在其他专栏中没有遇到过这个问题。任何帮助将不胜感激。

我想一种解决方案是将表的所有内容复制到另一个表,更改排序规则,然后再次将其移回。但如果可能的话,我宁愿不这样做。

编辑:

尝试了以下方法:

创建表 temptable (id int, document nvarchar(max))

insert into temptable (id, document) select GroupDocumentID, Document from GroupDocument

alter table GroupDocument drop column Document alter table temptable alter column document nvarchar(max) ALTER TABLE [GroupDocument] add [Document] ntext COLLATE Finnish_Swedish_CI_AS NULL

update GroupDocument set Document = (select temptable.document from temptable where temptable.id = GroupDocument.GroupDocumentID)

还是同样的问题。

导致问题的行有一个 7996 字节的 varchar,我猜 + 一些整数使其成为边界情况。

【问题讨论】:

  • 您并没有真正理解这个问题。 row size 不是一列上字符串的长度(而且,为了记录,VARCHAR(MAX) 可能更长),它是整行字节的实际大小,包括你的每一列表
  • 是的,我知道这一点。事情是。如果总大小
  • 在这种情况下,表格具有这种布局; “int、int、nvarchar(max)、datetime、bit、int、int”。除非它试图将数据存储在列中而不是行外,否则我看不到行大小超过 8060 字节的任何原因。 Jonas 还尝试使用“sp_tableoption 'Document', 'large value types out of row', 1”强制对大值类型使用行外存储。

标签: sql-server-2008


【解决方案1】:

我做了一个组合,强制较大的值不在行中。

EXEC sp_tableoption 'dbo.GroupDocument', '行外的大值类型', 1

清理桌子。

dbcc cleantable('ExamDoc', 'groupdocument', 0)

最后删除并重建表的索引。

解决了问题! :D

【讨论】:

    猜你喜欢
    • 2011-02-13
    • 2015-04-03
    • 2011-11-12
    • 1970-01-01
    • 2013-08-09
    • 1970-01-01
    • 2021-04-12
    • 2011-08-28
    • 2017-06-05
    相关资源
    最近更新 更多