原帖:http://blog.youkuaiyun.com/htl258/archive/2009/04/24/4106999.aspx
if
object_id
(
'
tb
'
)
is
not
null
drop
table
tb
go
create
table
tb(id
int
,name
varchar
(
50
)
not
null
)
go
create
proc
proc_t5
as
begin
select
1
/
0
end
go
create
trigger
tri_tb
on
tb
for
insert
as
begin
set
xact_abort
off
if
update
(name)
begin
save
tran
t1
exec
proc_t5
if
@@error
<>
0
rollback
tran
t1
else
commit
tran
t1
end
end
go
insert
into
tb
select
1
,
'
a
'
select
*
from
tb
--
tb有1 a
SQL触发器与过程示例
本文档展示了如何使用T-SQL创建一个简单的表格,并通过触发器调用一个包含错误处理的过程。具体包括:创建表格、过程及触发器的语法,触发器内部如何通过保存点进行事务控制以及错误检查。
1743

被折叠的 条评论
为什么被折叠?



