create table anclass
(
picname nvarchar(20),
picurl nvarchar(20)
)
create table nclass
(
picname nvarchar(20),
title nvarchar(20)
)
insert into anclass values('部门1','100人')
insert into anclass values('部门2','200人')
insert into anclass values('部门3','300人')
insert into nclass values('部门1','logo1')
insert into nclass values('部门1','logo11')
insert into nclass values('部门1','logo111')
insert into nclass values('部门2','logo2')
insert into nclass values('部门3','logo3')
select * from anclass
select * from nclass
create trigger upda
on anclass
for update
as
begin
if(update(picname))
begin
declare @picnameold nvarchar(20)
declare @picnamenew nvarchar(20)
select @picnameold=picname from deleted
select @picnamenew=picname from inserted
update nclass set picname=@picnamenew where picname=@picnameold
commit tran
end
end
go
create trigger dele
on anclass
for delete
as
begin
declare @picnameold nvarchar(20)
select @picnameold=picname from deleted
delete from nclass where picname=@picnameold
commit tran
end
go
update anclass set picname='doudou' where picname='部门1'
update anclass set picurl='101人' where picurl='100人'
delete from anclass where picname='部门3'
试试?
反正我试是可以的呵