如何自动更新数据库中的记录?????急!!!急!!!急!!!
我有一个表:
id name order pubdate flag
1 aaa a122 2004-5-10 1
2 bbb a1223 2004-5-11 1
3 ccc a1224 2004-5-12 1
4 ddd a1225 2004-5-12 0
我的问题是这样的,如过pubdate的日期为当今日期,则flag值就自动设为0
我自己写了个存储过程
CREATE PROCEDURE proc_material_price_guoqi
as
begin
declare crs_material scroll cursor
for select pubdate from material for update of pubdate
open crs_material
declare @row int
set @row = @@cursor_rows
while @row > 0
begin
declare @mydate datetime
fetch next from crs_material into @mydate
if (CONVERT(char(10), @mydate, 126) = CONVERT(char(10), GETDATE(), 126))
update material set flag=0 where current of crs_material
set @row = @row - 1
end
close crs_material
deallocate crs_material
end
GO
但我知道对不对?
不对的话怎么写,放到哪里sql server才能自动的监测着它?
大家帮忙!