在SQL Server中,可以使用以下方法来创建、删除、修改和查看触发器:
- 创建触发器:
CREATE TRIGGER trigger_name ON table_name AFTER INSERT, UPDATE, DELETE AS BEGIN -- 触发器逻辑代码 END;
- 删除触发器:
DROP TRIGGER trigger_name ON table_name;
- 修改触发器:
ALTER TRIGGER trigger_name ON table_name AFTER INSERT, UPDATE, DELETE AS BEGIN -- 修改后的触发器逻辑代码 END;
- 查看触发器:
SELECT name, type, type_desc, create_date FROM sys.triggers WHERE parent_id = OBJECT_ID('table_name');
需要注意的是,在创建、删除、修改和查看触发器时,需要有相应的权限。