score:5
Accepted answer
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)
)
More questions
- Add a unique constraint of a sql table as foreign key reference to an another sql table
- SQL reference another table as foreign key
- SQL Join - two foreign keys in the same table reference a primary key
- Update new foreign key column of existing table with ids from another table in SQL Server
- SQL DROP TABLE foreign key constraint
- How can I find out what FOREIGN KEY constraint references a table in SQL Server?
- Delete data with foreign key in SQL Server table
- SQL Server: Howto get foreign key reference from information_schema?
- How can I drop a table if there is a foreign key constraint in SQL Server?
- delete primary key row which is foreign key of another table
- SQL Table Foreign Key that is part of a Composite Primary Key
- SQL Server Create Table with Foreign Key
- How do I select a given number of rows for one table for each parent primary key in another table in sql server 2012?
- SQL Server : there are no primary or candidate keys in the referenced table that match the referencing column list in the foreign key 'FK'
- SQL Server : table with foreign key to itself with cascade delete
- Get records via foreign key in another table in Entity Framework 6
- Reference a foreign key and Add check constraint for column in parent table
- Can the table referenced by a foreign key depend on the contents of another field?
- How can I make a foreign key only able to reference a subset of rows in the target table
- SQL - Copying rows of the same table but with different foreign key ID
- Reference one foreign key to multiple primary keys in SQL Server 2014
- Creating a clustered index on a foreign key is frequently joined to another table
- Insert unique identifier foreign key into table in SQL Server
- Database Diagram not showing table relation when new foreign key reference is added in SSMS 20114
- Many to many relationship in SQL server - To add reference in foreign table when insertion does not happen in base table
- How to get SQL table foreign key types by a query
- Grab value from another table via foreign key
- How to insert the foreign key into a subtype table in SQL Server
- SQL Server Different ways of creating table with foreign key
- How to add a primary (Surrogate) key from one table into a foreign key of another table?
More questions with similar tag
- Tsql, is there a way to update row using an existing field in the row as part of a string in another field in the same row?
- Stored procedure dependencies in SQL Server Management Studio
- Connect to SQL Server Analysis Cube with Python (Anaconda)
- sql server select min value from matching datetime
- How do I identify the error row when using batch insert (INSERT INTO table2 SELECT * FROM table1)
- What does TOP 1 mean in an sql query?
- Grouping based on pattern Sql
- jpa incorrect syntax near 'limit'
- NHibernate LINQ BIGINT casting
- Execute built in function like object_definition('asdf') in a different database
- Union and Order By (SQL Server)
- how to put case condition in my Stored procedure
- Intersecting many Points with many Polygons
- Explicit conversion from data type date to bigint is not allowed
- Identify rows where time difference is insufficient SQL Server 2008 R2
- How to do an inner join to get rid of dupes
- SQL Server in-memory oltp transaction snapshot isolation
- SUM of columns from different tables
- Got errors when trying to deploy cube
- Number of total select statement for particular web page?
- What do you do in SQL Server to CREATE OR ALTER?
- SQL inserting data based on nested xpath
- A before delete trigger in SQL Server
- T-SQL String Concatenating multiple rows
- Connecting Python to MSSQL using Pymssql
- SQL Server Query is faster in SSMS when including execution plan
- sql averaging rows on same resultset
- SQL GROUPING on 2 fields to get the min value
- Warning SQL71502 - Procedure <name> has an unresolved reference to object <name>
- C# SqlCommand syntax for this SQL command
Source:
stackoverflow.com