create procedure Test
(@uid int,@time datetime)
as
update app_time set c_flag=0 where c_uid=@uid and c_time<@time
go

解决方案 »

  1.   

    传入两个参数(cuid,ctime)
    如果在表app_time.中如果c_uid=cuid而且,c_time<ctime时候,将c_flag更改为0;如果c_time>ctime,则c_time=ctime,c_flag=1
      

  2.   

    create procedure Test
    (@uid int,@time datetime)
    as
    update app_time set c_flag=0 where c_uid=@uid and c_time<@time
    update app_time set c_flag=1,c_time=ctime where c_uid<>@uid and c_time<@time
    go
      

  3.   

    不好意思,没看清
    create procedure Test
    (@uid int,@time datetime)
    as
    update app_time set c_flag=0 where c_uid=@uid and c_time<@time
    update app_time set c_flag=1,c_time=ctime where c_time>@time
    go
      

  4.   

    总是列名time 无效?怎么办?
      

  5.   

    我上面的c_time=ctime改成c_time=@time,应该是这里的错
      

  6.   

    create procedure Test
    (@cuid int,
    @ctime datetime)
    as
    update app_time set c_flag=0 where c_uid=@cuid and c_time<@ctime
    update app_time set c_flag=1,c_time=@ctime where c_uid=@cuid and c_time>@ctime
    go