过程改写触发器
create table testa (id int ,c int,col varchar(30)) go
create table testb (id int ,c int,col varchar(30)) go
--创建一个触发器
create trigger tri_test on testa for insert
as
declare @id int ,@c int ,@col varchar(30) ;
select @id = id ,@c = c,@col = col from inserted ;
if ( @c = 1 )
insert into testb select @id ,@c ,@col
例如就这个好了,怎么用过程改写一下
------解决方案--------------------2005以上版本:
create proc p_testa (@id int ,@c int ,@col varchar(30))
as
begin
begin try
begin tran
insert into testa
output inserted.id,inserted.c,inserted.col into testb
values(@id,@c,@col)
commit
end try
begin catch
print 'error'
rollback
end catch
end