0

I have to create a new table in SQL, but I have a problem.

I want to have a unique value in one field but only for a specific field in same table, similar like a one to many.

Table:
ID_Order 
Supplier 
ID_Supplier_Order

And now I want to have ID_Order unique for the table, and ID_Supplier_Order only for specific Supplier. Can I do it in one table, or I have to create a second for Suppliers?

Rich Benner
  • 7,873
  • 9
  • 33
  • 39
Manickus
  • 5
  • 6
  • 1
    Possible duplicate of [Add unique constraint to combination of two columns](http://stackoverflow.com/questions/15800250/add-unique-constraint-to-combination-of-two-columns) – indofraiser Aug 30 '16 at 12:42

1 Answers1

0

Taken from:

Add unique constraint to combination of two columns

CREATE UNIQUE INDEX uq_yourtablename
  ON dbo.yourtablename(column1, column2);
Community
  • 1
  • 1
indofraiser
  • 1,014
  • 3
  • 18
  • 50