if exists(select 1 from sysobjects where id=object_id('A'))
drop table A
goif exists(select 1 from sysobjects where id=object_id('#2'))
drop table #2
goif exists(select 1 from sysobjects where id=object_id('#3'))
drop table #3
go
create table A
(
bianhao varchar(20),
name varchar(20),
date datetime
)create table #2
(
ID int identity,
bianhao varchar(20),
xgmoney money
)create table #3
(
ID int identity,
bianhao varchar(20),
papernumber varchar(20)
)create trigger syn
on A
after insert
asdeclare @bianhao varchar(20)
select top 1 @bianhao=bianhao from A order by date desc
begin tran
insert #2(bianhao)
select @bianhao
declare @tmp int
set @tmp=@@identity
set rowcount @tmp
insert #3(bianhao)
select @bianhao from sysobjects
if @@error=0
commit tran
else
rollback trango--插入数据
insert A select 'AAAAAAA','name1',getdate()select * from A
select * from #2
select * from #3--删除临时表
drop table A
drop table #2
drop table #3
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货