I'm using SQL server 2012 from Microsoft and creating a table using the primary key of another table as foreign key here but it says there is a syntax error
CREATE TABLE [dbo].[STUDENT]
(
STUDENT_ID int not null Identity,
SCHOOL_ID INT NOT NULL,
CONSTRAINT PKEY PRIMARY KEY (STUDENT_ID),
CONSTRAINT FKEY FOREIGN KEY (USER_ID) REFERENCES USER (USER_ID)
);
it gives me and sql80001 error
please help
USER
is a reserved keyword in SQL Server . Use []
to escape the name
CREATE TABLE [dbo].[STUDENT]
(
STUDENT_ID int not null Identity,
SCHOOL_ID INT NOT NULL,
CONSTRAINT PKEY PRIMARY KEY (STUDENT_ID),
CONSTRAINT FKEY FOREIGN KEY (USER_ID) REFERENCES [USER] (USER_ID)
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.