SQL server2008 中的触发器怎么定义,以及应用
展开全部
create triger tr_类型_触发器名字 on 表名
触发类型:after | instead of
操作类型:insert | delete | update
as
begin
代码
end
插入数据同时获得自动增长的ID
insert into USERS output inserted.* values('111','111');
删除数据的同时 插入数据
select * from USERS
go
create trigger test on USERS
after
delete
as
insert into USERS (Name,Sex)
select Name,Sex from deleted
go
触发类型:after | instead of
操作类型:insert | delete | update
as
begin
代码
end
插入数据同时获得自动增长的ID
insert into USERS output inserted.* values('111','111');
删除数据的同时 插入数据
select * from USERS
go
create trigger test on USERS
after
delete
as
insert into USERS (Name,Sex)
select Name,Sex from deleted
go
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询