CREATE TRIGGER 触发器名称
ON 表名
{ FOR | AFTER | INSTEAD OF }
{ [ INSERT ] [ , ] [ DELETE ] [ , ]
   [UPDATE ] }
AS
  SQL 语句 [ ... n ] 

  删除触发器:

DROP TRIGGER 触发器名 [ , ... n ]

  修改触发器:

ALTER TRIGGER 触发器名称
ON 表名
{ FOR | AFTER | INSTEAD OF }
{ [ INSERT ] [ , ] [ DELETE ] [ , ]
   [UPDATE ] }
AS
  SQL 语句 [ ... n ] 

  开启和禁用:

disable trigger trigDB on database --禁用触发器
enable trigger trigDB on database --开启触发器


  提醒和保护:

print '删除了触发器***'
raiserror('数据一致性验证',16,1)
rollback transaction 

  示例

  在S表创建UPDATE触发器:

Create trigger tri_Updates
on s
for update
as
print 'the table s was updated'

  禁止删除SC表中成绩不及格学生的记录:

CREATE TRIGGER tri_del_grade
  ON SC FOR DELETE
  AS
    IF EXISTS(SELECT * FROM DELETED   
          WHERE Grade < 60)
      ROLLBACK 

 禁止将SC表中不及格学生的成绩改为及格:

create trigger tri_update_grade
on sc for update
as
  if update(grade)
  if exists(select * from inserted,deleted
  where inserted.sno=deleted.sno and inserted.grade>=60 and deleted.grade<60)
  begin
 print '不能将不及格的成绩改为及格'
  rollback
  end