使用SQL Server的语法问题

时间:2016-05-09 22:30:48

标签: sql-server

我正在为体育用品商店创建一个数据库,并且正在尝试为设备创建一个表格。这段代码有语法错误,我无法弄清楚问题是什么。

CREATE TABLE Equipment 
(
    EquipmentID Int NOT NULL IDENTITY(100,1) PRIMARY KEY,
    EquipmentName NChar(50) NOT NULL,
    Sport NChar(15) NULL,
    Manufacturer NChar(50) NULL,
    Price smallmoney NOT NULL,
    Quantity int NOT NULL,

    /*Sport must be one of the following*/
    CONSTRAINT SportCheck
        CHECK (Sport IN ('Baseball', 'Football', 'Basketball', 'Hockey', 
'Soccer'))

   CONSTRAINT ValidQuantity CHECK (Quantity >= 0),
);

1 个答案:

答案 0 :(得分:2)

您在CONSTRAINT ValidQuantity

之前错过了一个逗号
CREATE TABLE Equipment (
EquipmentID Int NOT NULL IDENTITY(100,1) PRIMARY KEY,
EquipmentName NChar(50) NOT NULL,
Sport NChar(15) NULL,
Manufacturer NChar(50) NULL,
Price smallmoney NOT NULL,
Quantity int NOT NULL,

/*Sport must be one of the following*/
CONSTRAINT SportCheck
Check (Sport IN ('Baseball', 'Football', 'Basketball', 'Hockey', 
'Soccer')),

CONSTRAINT ValidQuantity
Check (Quantity >= 0),
);