发布网友 发布时间:2022-04-22 07:56
共1个回答
热心网友 时间:2022-05-02 10:35
CREATE TRIGER trig_MyTrigger ON table AFTER INSERT
AS
BEGIN
DECLARE @cur CURSOR
DECLARE @courseid int
SET @cur = CURSOR FOR SELECT COURSEID FROM inserted
OPEN @cur
FETCH NEXT FROM @cur INTO @courseid
WHILE(@@FETCH_STATUS=0)
BEGIN
UPDATE table2
SET OPENTIME=xxxxx
WHERE COURSEID=@courseid
FETCH NEXT FROM @cur INTO @curseid
END
CLOSE @cur
DEALLOCATE @cur
END
循环里面的UPDATE语句就是你的修改语句
需要分支的话可以用IF...ELSE IF...ELSE分支语句
@courseid是插入的编号