如何在SQL Server中删除触发器?

发布于 2024-10-09 20:51:33 字数 99 浏览 0 评论 0原文

我需要删除 SQL Server 中的触发器。看起来应该很简单,但是因为有一种称为“删除触发器”的东西,即在删除时调用的触发器,所以似乎不可能找到有关如何实际删除已存在的触发器的资源。

I need to delete a trigger in SQL Server. Seems like it should be simple enough, but because there is a thing called a "delete trigger", a trigger that is invoked upon deletion, it seems impossible to find resources on how to actually delete an already existing trigger.

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

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

发布评论

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

评论(5

逐鹿 2024-10-16 20:51:33

删除触发器

从当前数据库中删除一个或多个触发器...

您可以通过删除触发器或删除触发器表来删除触发器。当删除表时,所有关联的触发器也会被删除。删除触发器后,有关触发器的信息将从 sysobjects 和 syscomments 系统表中删除。

使用 DROP TRIGGER 和 CREATE TRIGGER 重命名触发器。使用 ALTER TRIGGER 更改触发器的定义...

DROP TRIGGER:

Removes one or more triggers from the current database...

You can remove a trigger by dropping it or by dropping the trigger table. When a table is dropped, all associated triggers are also dropped. When a trigger is dropped, information about the trigger is removed from the sysobjects and syscomments system tables.

Use DROP TRIGGER and CREATE TRIGGER to rename a trigger. Use ALTER TRIGGER to change the definition of a trigger...

冰之心 2024-10-16 20:51:33

要删除触发器,可以这样做:

DROP TRIGGER [trigger_name];  

如果您想在删除之前检查天气触发器是否存在,请使用:

SELECT * FROM [sys].[triggers] WHERE [name] = 'MyTrigger'

有关更多信息,请查看 http://www.tsql.info/triggers/drop-trigger.phphttps: //stackoverflow.com/a/636470/2218697

To drop a trigger, this works:

DROP TRIGGER [trigger_name];  

If you want to check weather trigger exist before a drop, then use:

SELECT * FROM [sys].[triggers] WHERE [name] = 'MyTrigger'

For more check out http://www.tsql.info/triggers/drop-trigger.php and https://stackoverflow.com/a/636470/2218697

不忘初心 2024-10-16 20:51:33

对于 SQL Server 2016 及更高版本

DROP TRIGGER IF EXISTS [dbo].[trg]

https: //learn.microsoft.com/en-us/sql/t-sql/statements/drop-trigger-transact-sql

For SQL Server 2016 and above

DROP TRIGGER IF EXISTS [dbo].[trg]

https://learn.microsoft.com/en-us/sql/t-sql/statements/drop-trigger-transact-sql

北风几吹夏 2024-10-16 20:51:33

我可以使用以下查询删除触发器

DROP TRIGGER [Trigger_Name]

          (OR)            

DROP TRIGGER Trigger_Update

希望这一定有帮助......

I can Drop a Trigger with the Following Query

DROP TRIGGER [Trigger_Name]

          (OR)            

DROP TRIGGER Trigger_Update

Hope this Must helpfull...

她说她爱他 2024-10-16 20:51:33
DROP TRIGGER IF EXISTS [dbo].[trigger_name];
DROP TRIGGER IF EXISTS [dbo].[trigger_name];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文