SQL Server 2008 中的 ALTER TABLE SWITCH 分区失败

发布于 2024-08-30 01:47:42 字数 568 浏览 3 评论 0原文

我有一个临时表(stage_enrolments)和一个生产表(enrolments)。暂存表未分区,生产表已分区。我正在尝试使用 ALTER TABLE SWITCH 语句将临时表中的记录传输到生产环境。

更改表 dbo.stage_enrolments 切换到 dbo.enrolments PARTITION @partition_num;

但是,当我执行此语句时,出现以下错误:

ALTER TABLE SWITCH 语句失败。目标表“Academic.dbo.enrolments”由 1 个索引视图引用,但源表“Academic.dbo.stage_enrolments”仅由 0 个匹配索引视图引用

我在 dbo 上定义了相同的索引视图。 stage_enrolments 就像我在 dbo.enrolments 上所做的那样 - 尽管注册的视图是分区的。我尝试重新创建视图及其索引,检查所有选项是否相同,但得到相同的结果。如果我从 dbo.enrolments 视图中删除索引,那么它就可以正常工作。

我让它在另一组具有索引视图的表上工作,所以我不确定为什么它不适用于这些表。有谁知道为什么会发生这种情况?我还应该检查什么?

I have a staging table (stage_enrolments) and a production table (enrolments). The staging table isn't partitioned, the production table is. I'm trying to use the ALTER TABLE SWITCH statement to transfer the records in the staging table to production.

ALTER TABLE dbo.stage_enrolments
SWITCH TO dbo.enrolments PARTITION @partition_num;

However, when I execute this statement I get the following error:

ALTER TABLE SWITCH statement failed. Target table 'Academic.dbo.enrolments' is referenced by 1 indexed view(s), but source table 'Academic.dbo.stage_enrolments' is only referenced by 0 matching indexed view(s)

I have the same indexed view defined on dbo.stage_enrolments as I do on dbo.enrolments - although the view on enrolments is partitioned. I've tried recreating the views and their indexes checking that all options are the same but I get the same result. If I remove the index from the dbo.enrolments view then it works fine.

I have it working on another set of tables that have indexed views so I'm not sure why it isn't working for these. Does anyone have an idea as to why this may be occurring? What else should I check?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧情勿念 2024-09-06 01:47:42

现在问题已得到解决。我再次重新创建了索引视图,它现在可以工作了。除了索引名称之外,我实际上没有更改任何内容,所以我不确定问题是什么。

The problem has now been sorted. I've recreated the indexed view once again and it is now working. I haven't actually changed anything though other than the name of the index so I'm not sure what the problem was.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文