Hello.
I'm trying to create a couple of tables in my SqlServerCE database (sdf).
I'm using the following commands:
The first one goes OK, but the second one throws an exception saying:Code:CREATE TABLE SUBJECTS( CODE bigint NOT NULL CONSTRAINT SUBJECTS_PK PRIMARY KEY, NAME nVarChar(40) NOT NULL, SOKR nVarChar(10) NULL ) CREATE TABLE REGIONS( CODE bigint NOT NULL CONSTRAINT REGIONS_PK PRIMARY KEY, SUBJ_CODE bigint NULL CONSTRAINT SUBJECTS_CODE FOREIGN KEY REFERENCES SUBJECTS(CODE), NAME nVarChar(40) NOT NULL, SOKR nVarChar(10) NULL )
The constraint specified is not valid.
The question is, how should I add a foreign key to a table?




Reply With Quote