declare @tmp varchar(50)
declare SetNumber cursor
for select ID from STUDENT_TEST
open SetNumber
declare @STUDENT int
fetch next from SetNumber into @tmp
set @STUDENT=1
WHILE @@FETCH_STATUS = 0
begin
update STUDENT_TEST set student =RIGHT('00000000'+CAST(@STUDENT as varchar(10)),7) where ID=@tmp;
set @STUDENT=@STUDENT+1
FETCH NEXT FROM SetNumber INTO @tmp
end
CLOSE SetNumber
DEALLOCATE SetNumber