sql2008 作业 问题 请教高手帮忙写个作业数据库里面有一个表tb_book 里面有一个字段book_time, 现要求写个作业,把当前时间和book_time里面的值对比,如果大于3的话,就删除该条记录。到达到的目的是:3天内没有来处理的话,就自动删除该条记录 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 delete from tb_bookwhere datediff(day,getdate(),book_time)>3 #1. 写个更新的存储过程CREATE PROCEDURE proc_deleteAS DELETE FROM tb_book WHERE DATEDIFF(DAY, book_time, GETDATE()) > 3#2. 创建作业http://topic.csdn.net/t/20031210/22/2550568.html delete from tb_bookwhere datediff(dd,book_time,getdate())>3 delete from tb_bookwhere datediff(day,book_time,getdate())>3 ???--查询并保留记录备检select * into ##from tb_book where book_time < getdate() -3go--删除delete tb_book where book_time < getdate() -3 关于存储过程的问题。 排序问题(order by...) 怎么得到三种状态其中一个状态的所有记录 数据库中有些数据显示"???",不识别 是不是只要用了类型转换就能彻底防止sql injection。 SQL中in后面跟的数组数据量过大时报错怎么优化? 一个面试题,大家来看看 优化sql语句 求助:怎么才能做到把mssql服务器上的某个实例隐藏 不被别人在局域网内找到 請教大家,幾個表相聯的 sql 語句怎麼寫??? 謝謝!!! 在sql 2000语句的insert中可以使用for循环吗? 如何生成xml?
where datediff(day,getdate(),book_time)>3
CREATE PROCEDURE proc_delete
AS
DELETE FROM tb_book WHERE DATEDIFF(DAY, book_time, GETDATE()) > 3
#2. 创建作业
http://topic.csdn.net/t/20031210/22/2550568.html
where datediff(dd,book_time,getdate())>3
where datediff(day,book_time,getdate())>3
--查询并保留记录备检
select * into ##
from tb_book
where book_time < getdate() -3
go
--删除
delete tb_book where book_time < getdate() -3