Home > Database > Mysql Tutorial > What are the methods to delete triggers in sql

What are the methods to delete triggers in sql

清浅
Release: 2020-09-15 13:19:02
Original
20289 people have browsed it

There are two ways to delete triggers in sql: 1. Use SSMS database management tool to delete triggers; 2. Use [T-SQL] script to delete triggers, the code is [drop trigger trigger name;].

What are the methods to delete triggers in sql

There are two ways to delete triggers in sql:

1. Delete using SSMS database management tools Trigger

Delete DML trigger

1. Connect to the database, select the database, select the data table-》Expand Data table-"Expand trigger-"Right click-"Select delete.

What are the methods to delete triggers in sql

#2. In the delete object pop-up box - "Click OK -" you can see the deletion result without refreshing.

What are the methods to delete triggers in sql

Image 055.png

Delete DDL trigger

1. Connect to the database and select the database-》Expand Programmability -> Expand database triggers -> Right-click -> Select delete.

Image 056.png

#2. In the delete object pop-up box - "Click OK -" you can see the deletion result without refreshing.

What are the methods to delete triggers in sql

What are the methods to delete triggers in sql

Delete LOGON trigger

1. Connect to the database-》Expand the server object- 》Expand the trigger-》Right-click-》Select Delete.

Image 059.png

#2. In the delete object pop-up box - "Click OK -" you can see the deletion result without refreshing.

What are the methods to delete triggers in sql

What are the methods to delete triggers in sql

##2. Use T-SQL script to delete triggers

Syntax :

--Declare database reference


use 数据库;
go
Copy after login

--Determine whether it exists, if it exists, delete it


if exists(select * from sys.triggers where name=触发器名)
Copy after login

--Delete DML trigger


drop trigger 触发器名;
Copy after login

----Delete DDL trigger


--drop trigger 触发器名 on database;
Copy after login

--Delete login trigger


--drop trigger 触发器名 on all server;
go
Copy after login

Example: This example demonstrates Remove DML update trigger.

--Declare database reference

use testss;
go
Copy after login

--Determine whether it exists, if it exists, delete it

if exists(select * from sys.triggers where name='updatetri')
drop trigger updatetri;
go
Copy after login

Example result:

Image 052.png

The above is the detailed content of What are the methods to delete triggers in sql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template