设计表时:id2字段加公式:id*1

解决方案 »

  1.   

    哦 也可以的 只要能实现这个功能就行
    但我不知道怎么使id2和id1同步 汗............
      

  2.   

    这样吧,如果is null 就换成id 否则就是输入的值create tigger mytrig on yourtable instead of insert
    as
    begin
      insert yourtable select id1, isnull(id2,id1),content from inserted
    end
      

  3.   

    create trigger mytrig on yourtable instead of insert
    as
    begin
      insert yourtable select id1, isnull(id2,id1),content from inserted
    end
      

  4.   

    能不能不写触发器,用SQL语句实现?
    写触发器的话不好移植到其他数据库中去
    谢谢
      

  5.   

    必须用触发器:create trigger mytrig on yourtable after insert
    as
    begin
      update yourtable  set id2=id1 where exists (select 1 from inserted  where inserted.id1= yourtable.id1 and yourtable.id2 is null)
    end