日期:2014-05-18  浏览次数:20539 次

触发器中的 instead of 哪里出了问题?
我想在每次往临时表tempR表中存入数据之前先把这个表中的所有数据清空,然后才插入数据,所以建立了这个触发器:

create trigger 读者录入临时表触发器 on tempR
instead of insert
as
delete from tempR


当我向tempR表中插入一个数据时
insert into tempR values('u0041442')
却发现,这个触发器仅仅执行了删除操作却没有将'u0041442'插入到表tempR中,哪里出了错?

表tempR结构:
create table tempR(
num char(8)
)

------解决方案--------------------
instead of insert
本身就是意思代替 原先 insert的操作
------解决方案--------------------
如果你的意思要先删除原先所有数据再 执行插入语句应该这样 
create trigger 读者录入临时表触发器 on tempR 
instead of insert 
as
begin 
delete tempr
insert tempR select * from inserted
end
------解决方案--------------------
楼上正解
------解决方案--------------------
create trigger 读者录入临时表触发器 on tempR
instead of insert 
as 
begin
delete tempr
insert tempR select * from inserted 
end