SQLSERVER 游标的备份


Declare active_cursor Cursor Scroll  For select id from member where status=0  and is_valid_idcard = 1 and is_valid_mobile=1 and mobile is not null
Open active_cursor
declare @i int
declare @member_id int
Fetch next From active_cursor Into @member_id
While (@@Fetch_Status = 0)
Begin
Begin
 select @i=@i+1
 PRINT @i
 insert into million_active_result(member_id,award_no,status,remark,version,date_created,created_by,last_updated,updated_by)
 values (@member_id,cast(ceiling(rand() * 10000000) as int),0,'环游世界抽',1,getdate(),1,getdate(),1)
End
Fetch next From active_cursor Into @member_id
End
Close active_cursor
Deallocate active_cursor

你可能感兴趣的:(SQLSERVER 游标的备份)