August 10, 2011 at 2:27 am
I have table
create table T1(
id int,
name varchar(64),
isopen bit
)
And I Have an clustered index on T1 with partition scheme
ALTER TABLE T1 ADD CONSTRAINT PK_T1 PRIMARY KEY CLUSTERED
(
[ID] ASC,
[ISOPEN]
) PartitionScheme(ISOPEN)
GO
Up to this point, there is not any problem but if i want to add a foreign key which refers T1, I could not:
ALTER TABLE T2 WITH CHECK ADD CONSTRAINT FK_T2_T1 FOREIGN KEY(T1_ID)
REFERENCES T1 ([ID])
GO
And getting following error:
Msg 1776, Level 16, State 0, Line 1
There are no primary or candidate keys in the referenced table T1 that match the referencing column list in the foreign key FK_T2_T1
Msg 1750, Level 16, State 0, Line 1
Could not create constraint. See previous errors.
What do i have to do?
August 10, 2011 at 3:52 am
You have 2 columns in the primary key, 1 column in the foreign key
August 10, 2011 at 4:25 am
Yes but, i must provide referantial integrity
August 10, 2011 at 4:45 am
Ah sorry I didn't notice that it involved Partioning despite the thread title!
You either need to include that Partitioning column in the other table and denormalize, or....ermmm......not sure. I guess having a non partitioned index on a partitioned table isn't an option for you?
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply