declare @userid int
declare @username varchar(100)
declare @id int
 declare rs cursor for select userid,username,id from bs_know  where status=1 and dateadd(second,15,stardate)<=getdate()
open rs
FETCH rs  INTO @userid,@username,@id
while @@fetch_status=0
begin
update bs_member set score=score-20 where uid=@userid
update bs_know set status=4 where id=@id
insert into bs_score (userid,username,kind,cid,score) values (@userid,@username,2,@id,-20)
FETCH rs  INTO @userid,@username,@id
end