SQL Server 2012 无法创建任何表



我无法在SQL Server中创建任何表。错误字段总是说,我的表名附近有问题。

有人可以从第一个表中查看我的语法吗?

create table course
(c_id int not null AUTO_INCREMENT, 
 r_id int not null AUTO_INCREMENT,
 start date,    
 end date,
 name varchar(20),
 leader int,
 constraint pk_cousrse primary key (k_id, r_id, leader)
 );
insert into course (start, end, name, leader)
values (26.03.2012, 23.05.2013, , morrison);

是的,错误的部分是AUTO_INCREMENT 。 SQL Server中没有AUTO_INCREMENT。应该是IDENTITY.

同样,您正在尝试在表中创建两个IDENTITY字段。 这是不允许的。您只能有一个IDENTITY字段。

startend是保留词。您需要使用[](方括号(对它们进行转义

您的CREATE语句应如下所示

create table course (c_id int not null IDENTITY, r_id int not null , 
[start] date,
[end] date, 
name varchar(20), 
leader int, 
constraint pk_cousrse primary key (c_id, r_id, leader)
)

最新更新