[英]Sql syntax error - expecting ( or as
I am trying to write this SQL code: 我正在尝试编写以下SQL代码:
create table Users
{
UserID int primary key identity(200,1),
FirstName varchar(20) not null,
LastName varchar(20) not null,
BirthDate dateTime not null,
HomeTown varchar(30),
WorkPlace varchar(40),
Email not null
}
The problem is that next the {
symbol, I get the error: 问题是,下一个
{
符号,出现错误:
Incorrect syntax near '{'.
'{'附近的语法不正确。
When my mouse over the sign it adds: 当我将鼠标悬停在标志上时,它会添加:
Expecting '(' or AS
期待'('或AS
In addition, I also get an error on the values that are in the bracket 此外,括号中的值也出现错误
Incorrect syntax near '20'.
'20'附近的语法不正确。 Expecting '(' or Select".
期待'('或Select“。
The thing is that I have another SQL document (that I didn't write) and the same syntax work there! 问题是我还有另一个SQL文档(我没有写过),并且在那里有相同的语法! Why is that and how can I solve it?
为什么会这样,我该如何解决?
You need brackets not braces - http://www.w3schools.com/sql/sql_create_table.asp Also a data type for email 您需要方括号而不是大括号-http: //www.w3schools.com/sql/sql_create_table.asp也是电子邮件的数据类型
Ie 即
create table Users
(
UserID int primary key identity(200,1),
FirstName varchar(20) not null,
LastName varchar(20) not null,
BirthDate dateTime not null,
HomeTown varchar(30),
WorkPlace varchar(40),
Email varchar(40) not null
)
You have not specified the datatype
for Email
columnn. 您尚未为“
Email
列n指定datatype
。 Use ()instead of {}. 使用()代替{}。
Your sql statement should look like the following one, first change the {} to () then added the datatype to your email column 您的sql语句应类似于以下语句,首先将{}更改为(),然后将数据类型添加到您的email列中
create table Users (
UserID int primary key identity(200,1),
FirstName varchar(20) not null,
LastName varchar(20) not null,
BirthDate dateTime not null,
HomeTown varchar(30),
WorkPlace varchar(40),
[Email] varchar(255) not null
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.