日期:2014-05-17 浏览次数:21092 次
create trigger upstudentid
on StudentInfo
for update
As
if update(StudentID)
begin update StudentScore Set StudentID=i.StudentID
From StudentScore ss , Deleted d ,Inserted i
Where ss.StudentID=d.StudentID
end
create trigger upstudentid on StudentInfo after update
As
BEGIN
if update(StudentID)
begin
update StudentScore Set StudentID=i.StudentID
From StudentScore ss , Deleted d ,Inserted i
Where ss.StudentID=d.StudentID
end
END
go
create trigger tri_ins_a on A after insert,UPDATE
As
BEGIN
if update(NAME)
begin
INSERT INTO B(NAME)
SELECT NAME FROM Inserted i
end
END
if OBJECT_ID('table_Name1', 'u') is not null
drop table table_Name1
Create Table table_Name1
(
OID int identity(1, 1) primary key not null,
Name varchar(128) not null
)
if OBJECT_ID('table_Name2', 'u') is not null
drop table table_Name2
Create table table_Name2
(
OID int identity(1, 1) primary key not null,
Name1 varchar(128) not null
)
Create trigger InsertName on table_Name1
after Insert
as Insert into table_Name2(Name1) Select Name from Inserted