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

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,343 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,599 questions
0 comments No comments
{count} votes

Accepted answer
  1. Tom Phillips 17,721 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