Tuesday, March 6, 2018

Adding the group id with records.

Adding the group id with records.

create table #test(

id int identity(1,1)
,grp int
)
insert into #test(grp) values(0) ,(0),(0), (0),(0),(0), (0),(0),(0) ,(0),(0),(0)

update  #test set grp = ( (id-1)/3)+1-- 3 is number of records in gorup

select * from #test

No comments: