SQL Server 2008 中的 ALTER TABLE SWITCH 分区失败
我有一个临时表(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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
现在问题已得到解决。我再次重新创建了索引视图,它现在可以工作了。除了索引名称之外,我实际上没有更改任何内容,所以我不确定问题是什么。
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.