我决的写个触发器就可以了
IF EXISTS (SELECT name FROM sysobjects
      WHERE name = 'trig_mineAND' type = 'TR')
   DROP TRIGGER trig_minecreate trigger trig_mine on 表
for insert,update
as
   update 表 set flay=0 where exits(select * from inserted where pubdate=getdate()) 

解决方案 »

  1.   

    create table t (id char(5),name char(6),pubdate datetime,flag int)IF EXISTS (SELECT name FROM sysobjects
          WHERE name = 'trig_mine' and type = 'TR')
       DROP TRIGGER trig_mine
    go
    create trigger trig_mine on t
    for insert,update
    as
       update t set flag=0 where exists(select * from inserted where cast(pubdate as char(10))=cast(getdate() as char(10))) insert into t
       select 'aa1','a122','2004-5-11',1
      

  2.   

    Update material
    Set flag =Case When Cast(putdate As Char(10))=Cast(Getdate() As Char(10)) Then 0 Else 1 End 
     
      

  3.   

    --企业管理器--右键你的表--设计表--选择flag字段--在该字段的公式属性中输入:
    case datediff(day,pubdate,getdate()) when 0 then 0 else 1 end
      

  4.   

    --用语句就是:--如果flag字段已经建好,先删除它
    alter table 你的表 drop column flag
    go--再添加上去
    alter table 你的表 add flag as case datediff(day,pubdate,getdate()) when 0 then 0 else 1 end
      

  5.   

    这样设置公式后,flag字段的值就会自动生成,不需要自己去做修改调整