Home > Database > Mysql Tutorial > SqlServer添加触发器不让删除数据

SqlServer添加触发器不让删除数据

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:42:21
Original
1667 people have browsed it

SqlServer添加触发器不让删除数据 触发器是:instead of delete 类型,注意了:instead类型的触发器相当于: DELETE命令过来后,直接走触发器中的代码,再往下,没有了 就是说,这个触发器会屏蔽掉你所有的DELETED命令。而只会执行一下触发器中的代码。 如果

SqlServer添加触发器不让删除数据

触发器是:instead of delete 类型,网站空间,注意了:instead类型的触发器相当于:
DELETE命令过来后,美国服务器,直接走触发器中的代码,再往下,没有了……
就是说,这个触发器会屏蔽掉你所有的DELETED命令。而只会执行一下触发器中的代码。

如果你把这个触发器中的代码都注释掉,服务器空间,就相当于:屏蔽所有的DELETE命令。

 

Create trigger [dbo].[trg_del] on [dbo].[drv_user]
instead of delete
AS
BEGIN
declare @cou int
select @cou=count(*) from deleted;
if (@cou>0)
RAISERROR('数据不允许删除!', 16, 1)
END

posted on

Related labels:
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 Issues
Problem with tp6 connecting to sqlserver database
From 1970-01-01 08:00:00
0
0
0
Unable to connect to SQL Server in Laravel
From 1970-01-01 08:00:00
0
0
0
Methods of parsing MYD, MYI, and FRM files
From 1970-01-01 08:00:00
0
0
0
SQLSTATE: User login failed
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template