使用 DTS 复制检查约束时出错

发布于 2024-07-08 11:15:52 字数 290 浏览 8 评论 0原文

我有一个 DTS 包在“复制 SQL Server 对象”任务中引发错误。 该任务正在将表和数据从一台 SQL Server 2000 SP4 服务器复制到另一台(同一版本),并给出错误: -

无法找到“dbo.MyTableName”的 CHECK 约束,尽管该表被标记为具有一。

源表定义了一个检查约束,这似乎会导致问题。 运行 DTS 包后,事情似乎正常工作 - 表、所有约束和数据都在目标服务器上创建了吗? 但出现上述错误导致后续步骤无法运行。

知道为什么会出现这个错误吗?

I have a DTS package that is raising an error with a "Copy SQL Server Objects" task. The task is copying a table plus data from one SQL Server 2000 SP4 server to another (same version) and is giving the error: -

Could not find CHECK constraint for 'dbo.MyTableName', although the table is flagged as having one.

The source table has one check constraint defined that appears to cause the problem. After running the DTS package, the thing appears to work properly - the table, all constraints and data ARE created on the destination server? But the error above is raised causing subsequent steps not to run.

Any idea why this error is raised ?

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

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

发布评论

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

评论(2

路弥 2024-07-15 11:15:52

这表明 sys 表中的元数据与您的实际架构不同步。 如果您没有看到任何其他更普遍的损坏迹象,请通过将其复制到另一个表(从旧表中选择 * 到新表)来重建表,删除旧表,然后重命名新表并替换约束将帮助。 这类似于 2000 版企业管理器在插入不在表末尾的列时执行的操作,因此如果您不这样做,则在表中间插入新列然后删除将实现相同的效果不想手动编写查询。

如果您看到其他此类错误的发生,我会有点担心整个数据库的状态。 (我在这里假设您已经执行了 CHECKDB 命令并且错误仍然存​​在......)

This indicates that the metadata in the sys tables has gotten out of sync with your actual schema. If you aren't seeing any other signs of more generalized corruption, doing a rebuild of the table by copying it to another table (select * into newtable from oldtable), dropping the old table and then renaming the new one and replacing the constraints will help. This is similar to how the Enterprise manager for 2000 does things when you insert a column that isn't at the end of the table, so inserting a new column in the middle of the table and then removing will achieve the same thing if you don't want to manually write the queries.

I would be somewhat concerned by the state of the database as a whole if you see other occurrences of this kind of error. (I'm assuming here that you have already done CHECKDB commands and that the error is persisting...)

南冥有猫 2024-07-15 11:15:52

当向现有表添加新列(带有检查约束)时,会出现此错误。 为了调查我有: -

  • 将表复制到不同的目标 SQL Server 并得到相同的错误。
  • 创建了一个结构完全相同但名称不同的新表,并且复制没有错误。
  • 删除并重新创建问题表上的检查约束,但仍然出现相同的错误。
  • dbcc checktable ('MyTableName') with ALL_ERRORMSGS 没有给出错误。
  • 源数据库和目标数据库中的 dbcc checkdb 没有给出错误。

有趣的是,DTS 包似乎: -

  • 复制表。
  • 复制数据。
  • 创建约束

因为检查约束创建时间比表创建时间晚 7 分钟,即它在移动数据之后创建检查约束。 这是有道理的,因为它不必在复制时检查数据,这可能会提高性能。

正如 Godeke 所建议的,我认为系统表中的某些内容已经损坏,因为具有相同列的新表可以正常工作。 即使 DBCC 语句没有给出错误?

This error started when a new column (with a check constraint) was added to an existing table. To investigate I have: -

  • Copied the table to a different destination SQL Server and got the same error.
  • Created a new table with exactly the same structure but different name and copied with no error.
  • Dropped and re-created the check constraint on the problem table but still get the same error.
  • dbcc checktable ('MyTableName') with ALL_ERRORMSGS gives no errors.
  • dbcc checkdb in the source and destination database gives no errors.

Interestingly the DTS package appears to: -

  • Copy the table.
  • Copy the data.
  • Create the constraints

Because the check constraint create time is 7 minutes after the table create time i.e. it creates the check constraint AFTER it has moved the data. Makes sense as it does not have to check the data as it is copying, presumably improving performance.

As Godeke suggests, I think something has become corrupt in the system tables, as a new table with the same columns works. Even though the DBCC statements give no errors?

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