求SQL语句 在线等
表结构如下
datetime value
2011-11-25 2
2011-11-26 3
2011-11-27 4
2011-12-10 5
2011-12-11 6
求大侠指点一sql语句
将2011-11-25到2011-11-27(时间段作为参数) 的数据添加到2011-11-28 到2011-11-30 添加完成后如下
datetime value
2011-11-25 2
2011-11-26 3
2011-11-27 4
2011-11-28 2
2011-11-29 3
2011-11-30 4
2011-12-10 5
2011-12-11 6
[解决办法]
insert into a([datetime],[value]) select [datetime]+3[value]
from a
where [datetime]>='2011-11-25' and [datetime]<='2011-11-27'
[解决办法]
insert into a select datetime+3,value from a where datetime between '2011-11-25' and '2011-11-27'
[解决办法]
没看懂楼主是什么意思,可参考如下:
--获取两个时间之内的所有日期--sql 2000declare @sdate datetimedeclare @edate datetimeset @sdate = '2011-11-28'set @edate = '2011-11-30'select dateadd(dd,num,@sdate) dtfrom (select isnull((select count(1) from sysobjects where id<t.id),0) as num from sysobjects t) awhere dateadd(dd,num,@sdate)<=@edate/*dt ------------------------------------------------------ 2011-11-28 00:00:00.0002011-11-29 00:00:00.0002011-11-30 00:00:00.000(所影响的行数为 3 行)*/
[解决办法]