create table #t(nm varchar(2))
insert into #t(nm)
(
select 'aa' union
select 'bb' union
select 'cc' union
select 'dd' union
select 'ee' union
select 'ff' union
select 'bg' union
select 'hh'
)
create table #t1(id int identity,nm varchar(2),num int)
insert into #t1(nm) select nm from #t
update #t1 set num=case when id=id/3*3 then id/3 else id/3+1 end
select * from #t1