微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

【Sqlserver】修改数据库表中的数据:对缺失的数据根据已有的数据进行修补


1
--查询时间范围内的数据 2 select * from dbo.point where wtime >'2014-05-01 23:59:59' and wtime< '2014-05-02 00:40:42.000' 3 4 5 delete from point where wtime >'2014-05-01 23:59:59' and wtime< '2014-05-02 00:40:42.000' 6 7 --查询时间范围内的数据,并插入到临时表中 8 select * into a_temp from point where wtime between '2014-05-01 00:00:42.000' and '2014-05-01 00:40:42.000' 9 10 --查询临时表内的数据 11 select * from a_temp 12 13 14 --更新临时表的时间 15 update a_temp set wtime=DATEADD(day,1,wtime) 16 17 --把临时表中的数据插入到表中 18 insert into point select pointid,pointtype,pointvalue,pointunit,pointvalue2,pointunit2,wtime from a_temp

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐