做日程安排提醒时
比如有个表
sub    d_start                n_day
开会   2004-10-11  8:30        1表示“2004-10-11  8:30开会”,提前“1”天提醒。也就是说2004-10-10 8:30以后要提取出这条记录。Sql语句该怎么写?

解决方案 »

  1.   

    select * form 表名 where 现在时间+n_day<d_start时间
      

  2.   

    你需要对这个表做轮循,使用的sql语句如楼上的。
      

  3.   

    sorry!上面错了!!!
    select * form 表名 where d_start时间-n_day < 现在时间< d_start时间
      

  4.   

    select * from biao where getdate()>(d_start - n_day*1)
      

  5.   

    严重同意select * from biao where getdate()>(d_start - n_day*1)
      

  6.   

    select * from tableName where getdate()>(d_start-n_day)
      

  7.   

    业管理器
    --管理
    --SQL Server代理
    --右键作业
    --新建作业
    --"常规"项中输入作业名称
    --"步骤"项
    --新建
    --"步骤名"中输入步骤名
    --"类型"中选择"Transact-SQL 脚本(TSQL)"
    --"数据库"选择执行命令的数据库
    --"命令"中输入要执行的语句: select * from biao where getdate()>(d_start - n_day*1)
    --确定
    --"调度"项
    --新建调度
    --"名称"中输入调度名称
    --"调度类型"中选择你的作业执行安排
    --如果选择"反复出现"
    --点"更改"来设置你的时间安排
      

  8.   

    业管理器
    --管理
    --SQL Server代理
    --右键作业
    --新建作业
    --"常规"项中输入作业名称
    --"步骤"项
    --新建
    --"步骤名"中输入步骤名
    --"类型"中选择"Transact-SQL 脚本(TSQL)"
    --"数据库"选择执行命令的数据库
    --"命令"中输入要执行的语句: select * from biao where getdate()>(d_start - n_day*1)
    --确定
    --"调度"项
    --新建调度
    --"名称"中输入调度名称
    --"调度类型"中选择你的作业执行安排
    --如果选择"反复出现"
    --点"更改"来设置你的时间安排
    这样才是正解!