首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

历程改写触发器

2013-02-19 
过程改写触发器create table testa (id int ,c int,col varchar(30)) go create table testb (id int ,c i

过程改写触发器
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

热点排行