I'm getting an error from SQL Server 2000 and I don't understand why it is happening. I'm creating a bunch of tables, I'll only show the trouble makers though: create table "Queue" ( "FolderID" int not null, "QueryName" char(32) not null, "QueueName" char(32) not null, "DocType" char(12) not null, "CreatedBy" char(12) not null, "UpdatedBy" char(12) not null, "DateCreated" datetime default GetDate() not null, "DateUpdated" datetime default GetDate() not null, "Notes" text null, "QueryFolderID" int not null, "GridName" char(32) not null, "GridFolderID" int not null) goalter table "Queue" add constraint "Queue_PK" primary key ("QueueName", "FolderID") gocreate table "Query" ( "FolderID" int not null, "QueryName" char(32) not null, "Application" char(12) not null, "Library" char(12) not null, "DocType" char(12) not null, "Code" text not null, "CreatedBy" char(12) not null, "UpdatedBy" char(12) not null, "DateCreated" datetime default GetDate() not null, "DateUpdated" datetime default GetDate() not null, "Notes" text null) goalter table "Query" add constraint "Query_PK" primary key ("FolderID", "QueryName") go The problem happens when I try to create the foreign key. . . alter table "Queue" add constraint "Query_Queue_FK1" foreign key ( "QueryName", "QueryFolderID") references "Query" ( "QueryName", "FolderID") on update no action on delete no action go
When this alter table command executes I get this error:"There are no primary or candidate keys in the referenced table 'Query' that match the referencing column list in the foreign key 'Query_Queue_FK1'."Both the reference fields are part of the primary key for for Query however so I don't know what the problem is.Thanks in advance.Stan