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

解决方案 »

  1.   

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

  2.   

    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
      

  3.   

    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
      

  4.   

    Update news
    Set hits = hits+case when hits>20000 then 1 else datepart(second,getdate()) end
    Where ID = @id
      

  5.   

    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 
      

  6.   

    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