Check It Out!
1. Primary key Table1:
create Table Table1
(
Id Int Identity(1,1) Primary Key, Column1 varchar(10))
go
2. Primary key Table2:
create Table Table2
(
Id Int Identity(1,1) Primary Key , Column2 varchar(10))
go
3. Child Table3:
Create Table Table3
(
Id Int , Column3 varchar(10))
go
4. Enforcing Foreign key on "Table3" referring "Table1.ID" and Table2.ID"
Alter Table Table3 Add Constraint FK_Id Foreign Key(Id) References Table1(Id)
Go
Alter Table Table3 Add Constraint FK_Id1 Foreign Key(Id) References Table2(Id)
Go
Ih these case, Value should be there in both tables
Table1.Id and
Table2.Id then only you can use that value in
Table3.Id, So the FK constraint validates on both Referred table(s).
Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions
Parthibansk, if this helps please login to Mark As Answer. | Alert Moderator