日期:2014-05-17  浏览次数:20470 次

~~~~~~~~~日期范围周期判断,很难啊~~~~~~~~~
task_A 表
A_id   title      begin_date      end_date       time_desc(频率)
1      AAAA       2013-09-01      2013-09-13     周
2      BBBB       2013-09-03      2013-10-02     月
3      CCCC       2013-09-01      2013-10-08     季
4      DDDD       2013-06-19      2013-07-02     半年
5      EEEE       2013-01-08      2015-12-31     年

每天凌晨根据task_A频率和时间范围,把task_B 表符合的数据插入task_B
task_B 表
id     A_id


备注:周、月、季、半年、年都为自然周、月、季、半年、年

------解决方案--------------------
这种直接写一个JOB完成不好吗?还要依赖于表来完成?
------解决方案--------------------
try this,

insert into task_B(id,A_id)
 select [id值],A_id 
  from task_A 
  where getdate() between cast(begin_date as datetime) and cast(end_date as datetime)

------解决方案--------------------

“每天凌晨根据task_A频率和时间范围,把task_A 表符合的数据插入task_B”


时间范围是什么?
符合的数据?这个符合的条件是什么?

请重新把问题描述清楚。