日期:2014-05-19  浏览次数:20457 次

一个Table的记录,如果记录超过10天(以记录中的字段crt_date创建时间为标准)没更新,则将记录 中的某一字段值更改。
如题。
如table中记录如下:
code         name             size       type     flag   crt_date
001             书                 大         A             Y         2007-4-10
002             笔                 中         B             Y         2007-4-10
003             电脑             中         C             Y         2007-4-10

如这三条记录中如果在10天后,即2007-4-20后   没做任何更新,则将字段flag的值改为N

如何实现,谢谢

------解决方案--------------------
select * ,
[flag]=case when convert(varchar(10),crt_date,120) between convert(varchar(10),getdate(),120) and convert(varchar(10),getdate(),120) then 'N ' else 'Y ' end
from 表名