create table ta(ID int, name varchar(5), Content varchar(2)) insert ta select 1, '小明', '明' union select 2, '小张', '张' union select 3, '小曹', '曹'create trigger test_tr on ta instead of insert as set nocount on select * into # from ta where id>1 delete ta where id>1 insert ta select * from inserted insert ta select * from # 测试: insert ta select 4,'a','b' select * from ta
烧钱呀 其实让前台语言得到这个结果集 可以使用union all来做 select * from tbl where id=1 union all select * from tbl where id not in (1,2) union all select * from tbl where id=2 go 这样就可以把结果集返回给了前台语言了,至于插入操作就不象现在那样又麻烦又浪费资源了
create table ta(ID int, name varchar(5), Content varchar(2))
insert ta
select 1, '小明', '明'
union select 2, '小张', '张'
union select 3, '小曹', '曹'create trigger test_tr on ta
instead of insert
as
set nocount on
select * into # from ta where id>1
delete ta where id>1
insert ta select * from inserted
insert ta select * from #
测试:
insert ta select 4,'a','b'
select * from ta
其实让前台语言得到这个结果集
可以使用union all来做
select * from tbl where id=1
union all select * from tbl where id not in (1,2)
union all select * from tbl where id=2
go
这样就可以把结果集返回给了前台语言了,至于插入操作就不象现在那样又麻烦又浪费资源了