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列怎么写

解决方案 »

  1.   

    create trigger upstudentid on StudentInfo after update
    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
      

  2.   

    如果建完触发器后,有对StudentInfo表drop掉重建,触发器也会被drop掉,需重建关于触发器,可以参考一下海爷以前的一个帖子和博文触发器综述
      

  3.   

    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