SQL2005存储过程问题!

[复制链接]
查看11 | 回复3 | 2010-11-30 15:06:22 | 显示全部楼层 |阅读模式
我现在一张表里面有2个字段分别说 ste 和time,我的程序会在插入该表的时候插如ste为1,time为当前服务器时间,我需要一个存储过程每当程序运行的时候执行一次,查询今天日期是不是已经过了time 3天之后,如果过了3天,就自动讲ste修改为2!

回复

使用道具 举报

千问 | 2010-11-30 15:06:22 | 显示全部楼层
create procedure p_1asbeginif exists(select * from table1 where datediff(day,time,getdate())>3)update table1 set ste=ste+1end;
回复

使用道具 举报

千问 | 2010-11-30 15:06:22 | 显示全部楼层
那你要的不是存储过程而是触发器吧
回复

使用道具 举报

千问 | 2010-11-30 15:06:22 | 显示全部楼层
create procedure p_1asbeginupdate table1 set ste=2 where datediff(day,time,getdate())>3 and ste=1end;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行