Skip to content

Using Identity Columns as Primary Keys #442

Answered by Mimetis
satpal123 asked this question in Q&A
Discussion options

You must be logged in to vote

As @gentledepp mentioned, working with GUID is the most convenient way.

Another technic is to use seeding. You have two main methods:

Method 1:

The idea is to work with Identity columns as Primary keys and range of ids.
For instance, you can define something like that:

  • Server IDS range: 1 - 99 999 999
  • Client 1 IDS range: 100 000 000 - 100 999 999
  • Client 2 IDS range: 101 000 000 - 101 999 999
  • Client 3 IDS range: 102 000 000 - 102 999 999

You can store these values in any configuration table.
When you reach the limit for one client (or server), just change the range for a new one.

Method 2:

In the same concept, another technic is to use the IDENTITY (m, n) formula as follows:

  • m = Serial …

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
1 reply
@satpal123
Comment options

Comment options

You must be logged in to vote
7 replies
@Mimetis
Comment options

@gentledepp
Comment options

@Mimetis
Comment options

@gentledepp
Comment options

@satpal123
Comment options

Answer selected by satpal123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants