I have the following table:
ID
KEY_1
KEY_2
I want the combination of KEY_1 with KEY_2 to be unique and vice versa.
ALTER TABLE dbo.table_name
ADD CONSTRAINT uq_table_name UNIQUE(KEY_1, KEY_2);
This way I can make the combination between KEY_1 AND KEY_2 unique but I want the vice versa as well.
Example:
KEY_1 = 111;
KEY_2 = 222;
I cannot insert this values again or neither can I insert the values vice versa.
This shouldn't be valid (since it's the same pair of keys):
KEY_1 = 222;
KEY_2 = 111;
Thanks