Primary Key Identifier

SKV

Active Member
Joined
Jan 7, 2009
Messages
257
is there a way that let system selects the field combination to generate Primary key for that data base.

I have 50-60 fields and each has a repeating value at some point. So I want the system to check a combination of fields which can give me primary key for that data base.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
I can use Auto-number as I get a datapull every month in which records may be repeated.

IF I use the auto-number than during appending I will get duplicate records.




just insert an autonumber field into the table and have it be the primary key
 
Upvote 0
If you want you can create a compound key.
In the table design control-click the fields that you want to include in the key, then click the Primary Key icon and save the table. If it can't save you already have duplicates, and will need to correct that problem before creating the key.

Denis
 
Upvote 0
Yeh that is a option but I want the system to select the minimum required fields to make a primary key.

If you want you can create a compound key.
In the table design control-click the fields that you want to include in the key, then click the Primary Key icon and save the table. If it can't save you already have duplicates, and will need to correct that problem before creating the key.

Denis
 
Upvote 0
You'll probably need to write some code that picks your fields (say) four at a time, concatenates them, groups and looks for duplicates. That's a huge number of permutations.
Why don't you pick the 4 most likely, concatenate and group them, and if you find any duplicates keep adding one field at a time until you get a unique set. You can then use this combo as your key fields.

Denis
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,757
Members
448,991
Latest member
Hanakoro

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top