create trigger user_Delete//创建一个名为user_Delete的触发器 on User //针对于User表 for Delete //执行删除操作 as //执行完后要干的事情 Select* from User //查询user表 create trigger user_Delete//创建一个名为user_Delete的触发器 on User //针对于User表 //如果执行的是Delete事件将会被Select * from deleted 语句代替 instead of Delete as Select* from deleted //(查看你要删除的数据) create trigger user_Delete//创建一个名为user_Delete的触发器 on User //针对于User表 instead of Delete as declare @a nvarchar(200);//声明一个字符串类型的a的变量 Select @a = ids from deleted;//获取要删除的数据的ids列并赋值给a if @a = 5;//如果a=5 begin select '不能删除' end//不等于5 else begin delete from users where ids=@a end