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
这一个触发器创建之后打开看触发器就提示[dbo].[upstudentid]对象名无效
创建了其他类型的触发器打开也是提示对象名无效
另外求解
插入信息到A表,,A表有Name列,触发插入姓名到B表Name列怎么写
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
这一个触发器创建之后打开看触发器就提示[dbo].[upstudentid]对象名无效
创建了其他类型的触发器打开也是提示对象名无效
另外求解
插入信息到A表,,A表有Name列,触发插入姓名到B表Name列怎么写
As
BEGINif update(StudentID)
begin
update StudentScore Set StudentID=i.StudentID
From StudentScore ss , Deleted d ,Inserted i
Where ss.StudentID=d.StudentID
end ENDgocreate trigger tri_ins_a on A after insert,UPDATE
As
BEGINif update(NAME)
begin INSERT INTO B(NAME)
SELECT NAME FROM Inserted i end END
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