Link to home
Start Free TrialLog in
Avatar of mfony
mfony

asked on

Calculated identity field

I'd like to make a table that insures that I cannot have duplicate records based on a fund number and a date. Can I create an indentity field that a calculation between the two? With a single integer identity field I could have several records that have the same fund number and date.

Thanks for the help.
Avatar of Anubis2005
Anubis2005
Flag of Vanuatu image

You need to create a unique index on both fields.  I would imageine you have the two fields listed as below:

FundNumber int
FundDate datetime

If so, you can create a 'Primary Key' on both of these, otherwise you can create your primary key on just the 'FundNumber' column and then create a 'Unique Index' on both the columns to ensure there are no duplicates.

Hope this helps.
Avatar of mfony
mfony

ASKER

You say:

-you can create a 'Primary Key' on both of these

Does that mean identity field based on a calculation of fundnumber and funddata?

or

-create a 'Unique Index' on both the columns

Which would be the best way of going about it?
In order to give you the best answer I have to ask another question.. how is the data being generated?

Is it pre-set, meaning that you already have all the fund numbers and dates (a)
or are you needing to dynamically generate the fund numbers and use the current date (b)
Avatar of mfony

ASKER

The fund and date information will all be pre-set
ASKER CERTIFIED SOLUTION
Avatar of Anubis2005
Anubis2005
Flag of Vanuatu image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial