测试一.
--------------
create table tb1 (id int identity(1,1), a varchar(10))
create trigger tri_tb1 on tb1 INSTEAD OF insert
as
begin
insert tb1 (a)
select a from inserted
endinsert tb1(a)
select 'a'select * from tb1
/*
id a
-----------------
1 a
*/-------------------------------------------------------------------
-------------------------------------------------------------------测试一.
--------------
create table tb1 (id int identity(1,1), a varchar(10))
create trigger tri_tb1 on tb1 for insert
as
begin
insert tb1 (a)
select a from inserted
endinsert tb1(a)
select 'a'select * from tb1
/*
id a
-----------------
1 a
2 a
*/==========================================================
结论:FOR INSERT,插入动作完成后执行触发语句.
INDSTEAD OF INSERT,用触发语句来代替插入语句.这样理触对不对啊?
--------------
create table tb1 (id int identity(1,1), a varchar(10))
create trigger tri_tb1 on tb1 INSTEAD OF insert
as
begin
insert tb1 (a)
select a from inserted
endinsert tb1(a)
select 'a'select * from tb1
/*
id a
-----------------
1 a
*/-------------------------------------------------------------------
-------------------------------------------------------------------测试一.
--------------
create table tb1 (id int identity(1,1), a varchar(10))
create trigger tri_tb1 on tb1 for insert
as
begin
insert tb1 (a)
select a from inserted
endinsert tb1(a)
select 'a'select * from tb1
/*
id a
-----------------
1 a
2 a
*/==========================================================
结论:FOR INSERT,插入动作完成后执行触发语句.
INDSTEAD OF INSERT,用触发语句来代替插入语句.这样理触对不对啊?
解决方案 »
- 求一条sql搜索语句
- 急,我的存储过程错在哪里,感觉死循环了。
- 导出 excel 提示 OLE DB 提供程序 'Microsoft.Jet.OLEDB.4.0' 。
- sql servser 2008 属性按键错误问题
- log explorer生成的sql表如何使用,(关于明细表、转换timestamp的问题)
- 如何利用SQL语句得到用户表的主键字段名称?
- select into产生的表怎样打开
- 100 分求SQL SERVER 2000 个人版下载地址~ 谢谢~
- 某条记录的两列求合计的问题,简单的sql语句求教!!
- 关于比较统计的一个问题。
- 大家共同探讨一个数据同步的问题
- sql-server2000 的数据类型问题!
指定触发器只有在触发 SQL 语句中指定的所有操作都已成功执行后才激发。所有的引用级联操作和约束检查也必须成功完成后,才能执行此触发器。
如果仅指定 FOR 关键字,则 AFTER 是默认设置。
INSTEAD OF
指定执行触发器而不是执行触发 SQL 语句,从而替代触发语句的操作。
所以你的理解是对的