ahmed elbarbary

ahmed elbarbary

  • 995
  • 1.6k
  • 189.9k

How to update generated number field with number to every group from 1

Jun 7 2021 2:27 AM

I work on SQL server 2012 I face issue I need to update Generated Number on table testto get UNIQUE number to every group id

from 1 to 4so first group from groupid 1 to 4 will be as 1000so second group from groupid 1 to 4 will be as 1001so third group from

groupid 1 to 4 will be as 1002

create table test
(
FamilyId int,
PortionKey nvarchar(20),
GroupId int,
GeneratedNumber int
)
insert into test(FamilyId,PortionKey,GroupId,GeneratedNumber)
values
(12100,'ab',1,NULL),
(12100,'cd',2,NULL),
(12100,'eg',3,NULL),
(12100,'fb',4,NULL),
(12100,'am',1,NULL),
(12100,'fu',2,NULL),
(12100,'ab',3,NULL),
(12100,'cy',4,NULL),
(12100,'lf',1,NULL),
(12100,'ad',2,NULL),
(12100,'gb',3,NULL),
(12100,'mu',4,NULL)

if i get unique number for every group of portion key from 1 to 4 then it accepted for menever mind 1000 or not but must be uniqueportion key on table test not repeatedI need every group id from 1 to 4 to get unique numberbased on group id and portion key

102815-image.png


Answers (1)