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

What are the methods to delete triggers in sql

清浅
清浅Original
2019-05-11 15:53:1020107browse

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

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


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

--Delete DML trigger


drop trigger 触发器名;

----Delete DDL trigger


--drop trigger 触发器名 on database;

--Delete login trigger


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

Example: This example demonstrates Remove DML update trigger.

--Declare database reference

use testss;
go

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

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

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!

Statement:
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