December 31, 2002 at 5:56 am
As a newbie db designer, I am having trouble creating a compound constraint.
I have two columns, both have many values which are duplicate, but I need them together to have unique values. e.g.
Column A Column B
BST AFR
BST ABC
C&E AFR
However, SQL keeps telling me that there are duplicates when I try and create the key. Also, I would like one of the columns to have null values, can I do this and have the constraint?
Regards
Anthony Fletcher Rogers
December 31, 2002 at 8:19 am
You can use constraints on muliple columns with null values.
Have you checked your table to make sure it doesn't already have a duplicate combination?
suggestion:
select col_a, col_b, count(*)
from table
group by col_a, col_b
having count(*) > 1
This will verify that what you want to constrain hasn't already been violated.
Check out 'constraints unique' in Books OnLine.
Michelle
January 2, 2003 at 4:49 am
Thanks for your help, rogue duplicates was the cause of the problem!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply