Open CurName
Fetch Next From CurName into @id,@nwhile if(@@fetch_status=0) 
begin
if (@id>5)
begin
Update table1
Set n=n+1
where current of CurName end
Fetch Next From CurName into @id,@n
end
Close CurName
Deallocate CurName