I am converting a class that uses the Identity generator to one that uses hilo. I'm also using a single table with distinct row per entity:
EntityId (table)
- EntityName
- NextHigh
Old Table:
Patients (table)
- Id (identity)
New Table:
PatientRecord (table)
- Id
To retain data integrity, I just use the existing Patients.Id as the new PatientRecord.Id:
insert into PatientRecord (Id)
select Id from Patients
And create an EntityId
entry:
insert into EntityId values ('PatientRecord', ??)
where ??
is the next hi value. What value should I use here? By default, initializing the column would be 1. Do I just use that, or should I use something like select MAX(Id) from PatientRecord
?