Error in creating a table

  • I want to create a table which contains a foreign key that referes to another table. SSMC says it' s good when I parse the SQL comand

    but I execute it the following error message appears

    Msg 8135, Level 16, State 0, Line 2

    Table level constraint does not specify column list, table 'JUDETE'.

    Here is the code

    USE Test;

    CREATE TABLE STATES

    (

    [#S] INT NOT NULL,PRIMARY KEY,

    NameState VARCHAR(32) NOT NULL,

    Country INT NOT NULL,

    CONSTRAINT FKCountry FOREIGN KEY (Country) REFERENCES COUNTRIES ([#C])

    );

  • Remove the comma which is just before Primary Key Keyword.

  • Thanks, it works now. The error was because I forgot to declare as key #T.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply