Warren Duhaylungsod
Warren Duhaylungsod

Reputation: 1

How can I have 2 foreign keys in SQL Server 2008?

Simple question but seems very difficult for me. I need 2 foreign keys in my table and after, will use query builder to get specific columns that I need.

Here is an image:

enter image description here

Currently, the ProductID already has a relation with my Products table. What I want now is to have another relation with my CustomerID to my CustomerProducts table. Any idea or reference on how to do it?

Upvotes: 0

Views: 34

Answers (1)

freakyhat
freakyhat

Reputation: 471

Why not just use code to create the foreign keys?

ALTER TABLE YourTable
ADD CONSTRAINT NameYourFK FOREIGN KEY (YourColumn) REFERENCES YourOtherTable (YourOtherIdentityColumn)

Upvotes: 1

Related Questions