question

AsadKhan-7718 avatar image
0 Votes"
AsadKhan-7718 asked AsadKhan-7718 commented

Incorrect syntax for definition of the 'TABLE' constraint

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-generalsql-server-transact-sql
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

TomPhillips-1744 avatar image
0 Votes"
TomPhillips-1744 answered AsadKhan-7718 commented

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://docs.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql?view=sql-server-ver15#foreign-key-constraints

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you so much I found the issue
I for got to mentioned my foreign key in the table

0 Votes 0 ·