举例:create table a (a int,aa varchar(100))
create table b (b int,bb varchar(100))
go
create view c
as
select a.*,b.* from a,b where a.a=b.b
go--测试:
insert c values(1,'aa',1,'bb')
--失败go
CREATE TRIGGER 名 on c
INSTEAD OF INSERT
AS
BEGIN
  INSERT a select a,aa from inserted
  INSERT b select b,bb from inserted
END
go--测试:
insert c values(1,'aa',1,'bb')

解决方案 »

  1.   

    创建一个触发器当实现INSERT的时候就UPDATE此表。create trigger t_update on a instead of insert 
    as
    begin
     update b set b.colname=...
     ..
    end
    go
      

  2.   

    create proc proc_in
    ...
    as
    insert into tablea values(....)
    insert into tableb values(....)create proc proc_up
    ...
    as
    update tablea
    set ....
    update tableb
    set ....
    用存储过程也行,需要在过程里面同时写2个插入语句,2个修改语句
    建议你用触发器好些