求教一条触发器的写法
我在数据库里输了一条记录作为头记录如:总公司
要做一个触发器 使这条记录不能被删除和修改 请教下该怎么写啊?
------解决方案--------------------create trigger undelete
on 表
for delete
as
set nocount on
if exists (select 1 from deleted where 条件=你想保留的数据)
begin
insert 表 select * from deleted where 条件=你想保留的数据
end
set nocount off
go
------解决方案--------------------create trigger undelete
on 表名
for delete,update
as
if exists (select 1 from deleted where 总公司)
begin
rollback
print'总公司不许被修改或删除'
end
go