Incorrect syntax for definition of the 'TABLE' constraint

Asad Khan 21 Reputation points
2021-09-30T16:41:47.3+00:00

CREATE TABLE zombie_neutralization (
certificateID INT NOT NULL IDENTITY,
date_certificate DATE NOT NULL DEFAULT getDate(),
renewal_date DATE NOT NULL DEFAULT getDate(),
training_hour INT NOT NULL,
CONSTRAINT PK_certi PRIMARY KEY (certificateID),
References HR.Employees(empid),
CONSTRAINT FK_employees FOREIGN KEY (empid)

);

I tried to remove the comma that is above references

Developer technologies Transact-SQL
SQL Server Other
0 comments No comments
{count} votes

Accepted answer
  1. Tom Phillips 17,771 Reputation points
    2021-09-30T17:05:29.86+00:00

    References is on the wrong line:

    CREATE TABLE zombie_neutralization (  
    certificateID INT NOT NULL IDENTITY,  
    date_certificate DATE NOT NULL DEFAULT getDate(),  
    renewal_date DATE NOT NULL DEFAULT getDate(),  
    training_hour INT NOT NULL,  
    CONSTRAINT PK_certi PRIMARY KEY (certificateID),  
    CONSTRAINT FK_employees FOREIGN KEY (empid) References HR.Employees(empid)  
    );  
    

    See: https://learn.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql?view=sql-server-ver15#foreign-key-constraints


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.