“目标表创建后,架构已更改。重新运行Select Into查询。“:

时间:2022-09-21 07:25:36

I have some code that disables a trigger on a table, runs an update, and reenables the trigger. It doesn't drop the source table or update the schema.

我有一些代码禁用表上的触发器,运行更新,并重新启用触发器。它不会删除源表或更新架构。

This would all be fine, but at the same time there are separate queries running that use that table as the source for a SELECT INTO. For some reason, when the two queries are running at the same time, I get this error:

这一切都很好,但同时运行单独的查询,使用该表作为SELECT INTO的源。出于某种原因,当两个查询同时运行时,我收到此错误:

Schema changed after the target table was created. Rerun the Select Into query.

创建目标表后,架构已更改。重新运行Select Into查询。

(I'm selecting into a temp table.)

(我正在选择临时表。)

So, my first question:

那么,我的第一个问题:

Does calling "DISABLE TRIGGER" or "ENABLE TRIGGER" change the schema of a table in TSQL?

调用“DISABLE TRIGGER”或“ENABLE TRIGGER”会改变TSQL中表的架构吗?

And my second question:

我的第二个问题:

Why would the second query report a schema change, when the destination is a temp table?

当目标是临时表时,为什么第二个查询会报告架构更改?

2 个解决方案

#1


apparently calling "DISABLE TRIGGER" or "ENABLE TRIGGER" does change the schema of a table. there is probably a catch all bit flag in a system table that tracks this change and is causing you grief.

显然称为“DISABLE TRIGGER”或“ENABLE TRIGGER”会改变表的架构。系统表中可能有一个捕获所有位标志,用于跟踪此更改并导致您悲伤。

possibly you could "tell" the trigger to "not run" in a different way. create a table and insert a row, within the trigger check existance of a row in that table, if it exists, return 0, otherwise do the processing. now just insert/delete this row as necessary...

可能你可以用不同的方式“告诉”触发器“不运行”。创建一个表并插入一行,在触发器中检查该表中一行的存在,如果存在,则返回0,否则进行处理。现在只需根据需要插入/删除此行...

#2


You do not ever want to disable triggers on a production system that is not in single user mode or you may have serious data integrity issues. It disables the tirgger fo all users not just you. I think you need to find a differnt way to handle your problem if you want your daqtabase to operate properly.

您不希望在非单用户模式的生产系统上禁用触发器,或者您可能存在严重的数据完整性问题。它禁止所有用户使用tirgger,而不仅仅是你。如果您希望daqtabase正常运行,我认为您需要找到一种不同的方法来处理您的问题。

#1


apparently calling "DISABLE TRIGGER" or "ENABLE TRIGGER" does change the schema of a table. there is probably a catch all bit flag in a system table that tracks this change and is causing you grief.

显然称为“DISABLE TRIGGER”或“ENABLE TRIGGER”会改变表的架构。系统表中可能有一个捕获所有位标志,用于跟踪此更改并导致您悲伤。

possibly you could "tell" the trigger to "not run" in a different way. create a table and insert a row, within the trigger check existance of a row in that table, if it exists, return 0, otherwise do the processing. now just insert/delete this row as necessary...

可能你可以用不同的方式“告诉”触发器“不运行”。创建一个表并插入一行,在触发器中检查该表中一行的存在,如果存在,则返回0,否则进行处理。现在只需根据需要插入/删除此行...

#2


You do not ever want to disable triggers on a production system that is not in single user mode or you may have serious data integrity issues. It disables the tirgger fo all users not just you. I think you need to find a differnt way to handle your problem if you want your daqtabase to operate properly.

您不希望在非单用户模式的生产系统上禁用触发器,或者您可能存在严重的数据完整性问题。它禁止所有用户使用tirgger,而不仅仅是你。如果您希望daqtabase正常运行,我认为您需要找到一种不同的方法来处理您的问题。