我试图将此MySQL转换为MS SQL Server,但出现以下错误
第102层15级州立69行 “ PENDING”附近的语法不正确。
我从MySQL的字段名称中删除了所有的'`',并且还更改了Unsigned。
DROP TABLE IF EXISTS `appointments`;
CREATE TABLE `appointments` (
`appointment_id` int(10) UNSIGNED NOT NULL,
`clinic_id` int(10) UNSIGNED DEFAULT NULL,
`user_id` int(10) UNSIGNED NOT NULL,
`patient_name` varchar(255) DEFAULT NULL,
`patient_phone` varchar(20) DEFAULT NULL,
`appointment_date` date NOT NULL,
`appointment_time` time DEFAULT '00:00:00',
`appointment_status` enum('PENDING','ACCEPTED','DECLINED','VISITED') NOT NULL DEFAULT 'PENDING',
`is_rescheduled` tinyint(1) DEFAULT '0',
`is_cancelled` tinyint(1) DEFAULT '0',
`cancel_reason` varchar(255) DEFAULT NULL,
`amount` decimal(10,2) DEFAULT NULL,
`fee` decimal(10,2) DEFAULT NULL,
`is_paid` tinyint(1) DEFAULT '0',
`causer_id` int(11) DEFAULT NULL,
`causer_type` varchar(255) DEFAULT NULL,
`availability_id` int(10) UNSIGNED NOT NULL,
`advice` varchar(500) DEFAULT '''''',
`diagnosis` varchar(500) DEFAULT '''''',
`appointment_created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`appointment_updated_at` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
`deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
进入
[Appointment_Id] int CHECK ([Appointment_id] > 0) NOT NULL,
[Clinic_Id] int CHECK ([Clinic_id] > 0) DEFAULT NULL,
[User_Id] int CHECK ([User_id] > 0) NOT NULL,
[Patient_Name] varchar(255) DEFAULT NULL,
[Patient_Phone] varchar(20) DEFAULT NULL,
[Appointment_Date] date NOT NULL,
[Appointment_Time] time(0) DEFAULT '00:00:00',
[Appointment_Status] enum('PENDING','ACCEPTED','DECLINED','VISITED') NOT NULL DEFAULT 'PENDING',
[Is_Rescheduled] smallint DEFAULT '0',
[Is_Cancelled] smallint DEFAULT '0',
[Cancel_Reason] varchar(255) DEFAULT NULL,
[Amount] decimal(10,2) DEFAULT NULL,
[Fee] decimal(10,2) DEFAULT NULL,
[Is_Paid] smallint DEFAULT '0',
[Causer_Id] int DEFAULT NULL,
[Causer_Type] varchar(255) DEFAULT NULL,
[Availability_Id] int CHECK ([availability_id] > 0) NOT NULL,
[Advice] varchar(500) DEFAULT '''''',
[Diagnosis] varchar(500) DEFAULT '''''',
[Appointment_Created_at] datetime2(0) NULL DEFAULT GETDATE(),
[Appointment_Updated_at] datetime2(0) NULL DEFAULT NULL,
[Deleted_at] datetime2(0) NULL DEFAULT NULL
) ;
答案 0 :(得分:1)
枚举似乎在SQL SERVER中不可用,请尝试CHECK
[Appointment_Status] varchar(10) NOT NULL
CHECK (Appointment_Status IN('PENDING','ACCEPTED','DECLINED','VISITED')) DEFAULT 'PENDING',