插入方法后触发

时间:2013-03-01 18:18:43

标签: sql sql-server

我正在尝试构建触发器,当用户在删除用户后删除一行时,将能够查看他删除的行。

我试过我的coading如下 请帮忙。

create trigger insertion
before insert on client
for each row
as
select * from client

3 个答案:

答案 0 :(得分:1)

试试这个:

create trigger deltrig 
on client 
for delete 
as 
   select deleted 

答案 1 :(得分:1)

delete from [<YourTable>] output deleted.*
/* where ... */

答案 2 :(得分:0)

这不是你想要的东西吗?

create table #deleted(nr int)
create table #teste_d(nr int)
insert into #teste_d 
values(1),(2),(3)

delete from #teste_d
OUTPUT deleted.nr INTO #deleted
where nr = 2

select * from #deleted

drop table #deleted
drop table #teste_d

结果集将被删除

或者如果你真的想使用触发器 应该改为删除或更新

你应该做点什么

 insert into ##Data_deleted (col1,col2,...)
 select col1,col2,... from deleted