当登记表中有插入时,我需要减少表计划中的计数器:
CREATE TRIGGER [UpdateEnrollmentsTrigger]
ON [TBLENROLLMENT_ENR]
FOR INSERT
AS
BEGIN
DECLARE @ScheduleCode NVARCHAR
DECLARE @TotalSlots INT
IF EXISTS(SELECT SCH_CODE FROM inserted)
BEGIN
SELECT @ScheduleCode = SCH_CODE FROM inserted
SELECT @TotalSlots = SCH_TOTALSLOTS FROM TBLSCHEDULES_SCH
WHERE SCH_CODE = @ScheduleCode
UPDATE TBLSCHEDULES_SCH
SET SCH_FREESLOTS = @TotalSlots - 1
WHERE SCH_CODE = @ScheduleCode
END
END
当我尝试创建此触发器时,VS12 的查询窗口显示:
SQL46010 :: Incorrect syntax near ].
提前致谢。