Our team is developing a new system for some organization. We have a Client
table:
Id (PK), int, not null
NoClient, int, not null
The organization often refers to the Client by its number NoClient
. Slowly, clients from the old system will be migrated (manually) to the new system.
NoClient
should be auto-increment (for new clients | feature of the new system) while allowing manual input (for existing clients) and not cause collisions later.
Visually, from the point of view of the auto-increment column:
..., 9998, 9999, (used), 10001, 10002
Any idea on how to leverage SQL Server 2005 (or Entity Framework) to solve that problem?
Will likely have to create a seed table and use stored procedures (logic embedded) unless there's a better way to do this...
Your question was not very clear.
Have a bool column active. Load all existing with the column false. Then just turn it on when the customer is migrated.
As for finding holes.
select min(tb1.PK) + 1
from table tb1
left outer join table tb2
on tb2.pk = tb1.pk + 1
where tb2.pk is null
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.