简体   繁体   English

需要帮助来创建简单的SQL数据库。 错误如下:消息102,级别15,状态1,第2行','附近的语法不正确

[英]Need assistance to create a simple SQL database. Error is as follows: Msg 102, Level 15, State 1, Line 2 Incorrect syntax near ','

I just need a little help with an error I am receiving when trying to create a table in SQL Server 2008 Management Studio. 在尝试在SQL Server 2008 Management Studio中创建表时遇到的错误,我只需要一点帮助。 The table I am trying to construct is: (This is only a small portion of the database which contains multiple tables similar to this one being constructed) 我要构造的表是:(这只是数据库的一小部分,其中包含与正在构造的多个表相似的多个表)

create table Holidays (
   staff_ID numeric(10) foreign key,
   start_Date date,
   fin_Date date,
   holiday_Type char(100),
   reason nvarchar(100),
);

The error I am receiving is: 我收到的错误是:

Msg 102, Level 15, State 1, Line 2 Msg 102,第15级,状态1,第2行
Incorrect syntax near ','. ','附近的语法不正确。

NOTE: I have created tables before in a similar fashion to this, and have looked over them to compare the differences (to which I can see is almost none). 注意:之前,我以类似于此的方式创建了表,并查看了表以比较差异(我几乎看不到差异)。

Any help is much appreciated. 任何帮助深表感谢。

You have one "," extra on the end , also your foreign key mentioned badly. 末尾有一个“,”号,也很糟糕地提到了您的外键。 Try this: 尝试这个:

create table Holidays ( 
staff_ID numeric(10) foreign key references Table(Column), 
start_Date date, fin_Date date, holiday_Type char(100), 
reason nvarchar(100))

You have an extra comma after your last column definition. 在最后一个列定义之后,您还有一个逗号。 Try this: 尝试这个:

create table Holidays (
staff_ID numeric(10) foreign key,
start_Date date,
fin_Date date,
holiday_Type char(100),
reason nvarchar(100) -- removed comma from here
); 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 消息 102,级别 15,State 1,第 8 行 '-' 附近的语法不正确,授予视图 SQL 服务器错误 - Msg 102, Level 15, State 1, Line 8 Incorrect syntax near '-' , Grant View SQL Server error SQL查询抛出此错误Msg 102,级别15,状态1,行1''附近的语法不正确 - SQL query is throwing this error Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ' ' SQL 错误:消息 102,级别 15,State 1,第 4 行“,”附近的语法不正确 - SQL ERROR : Msg 102, Level 15, State 1, Line 4 Incorrect syntax near ',' 消息102,级别15,状态1,第13行''附近的语法不正确 - Msg 102, Level 15, State 1, Line 13 Incorrect syntax near '?' 消息102,级别15,状态1,第8行在“ month”附近的语法不正确 - Msg 102, Level 15, State 1, Line 8 Incorrect syntax near 'month' 消息102,级别15,状态1,行1'''附近的语法不正确 - Msg 102, Level 15, State 1, Line 1 Incorrect syntax near '(' 消息102,级别15,状态1,第2行','附近的语法不正确 - Msg 102, Level 15, State 1, Line 2 Incorrect syntax near ',' 消息102,级别15,状态1,第1行'/'附近的语法不正确 - Msg 102, Level 15, State 1, Line 1 Incorrect syntax near '/' 消息102,级别15,状态1,行1'''附近的语法不正确 - Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ' ' 消息102,级别15,状态1,第3行'='附近的语法不正确 - Msg 102, Level 15, State 1, Line 3 Incorrect syntax near '='
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM