首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

60分修改一个简单的统计存储过程解决办法

2012-01-29 
60分修改一个简单的统计存储过程这是以前的一个,点击一次加1CREATEPROCEDUREaddcount@IDintASUpdatenewsSe

60分修改一个简单的统计存储过程
这是以前的一个,点击一次加1
CREATE   PROCEDURE   addcount
@ID   int
AS
Update   news
Set   hits   =   hits   +   1
Where   ID   =   @ID
GO
现在修改的要求如下:
点击一下,判断数据表中点击数是否大于20000,如果大于20000,就加1
否则就加上当前时间的秒数。
马上结贴,谢谢

[解决办法]
CREATE PROCEDURE addcount
@ID int
AS
Update news
Set hits = hits + datepart(ss,getdate())
Where ID = @ID and hits> 20000
GO

[解决办法]
CREATE PROCEDURE addcount
@ID int
AS
Update news
Set hits = hits + case when hits> 20000 then 1 else DATEPART(second,getdate()) end
Where ID = @ID
GO

[解决办法]
CREATE PROCEDURE addcount
@ID int
AS
Update news
Set hits = hits + (case when hits> 20000 then 1 else datepart(ss,getdate()) end)
Where ID = @ID
GO
[解决办法]
没看清楚....
[解决办法]
支持楼上
[解决办法]
Update news
Set hits = hits+case when hits> 20000 then 1 else datepart(second,getdate()) end
Where ID = @id

[解决办法]
CREATE PROCEDURE addcount
@ID int
AS
Update news
Set hits = hits + case when hits> 20000 then 1 else datepart(second,getdate()end
Where ID = @ID

热点排行