文章詳情頁
Sql server觸發器示例
瀏覽:104日期:2023-10-27 17:21:52
==========================================--insert 觸發器 create trigger tri_inserton studentfor insert as declare @student_id char(10)select @student_id=s.student_id from student s inner join inserted ion s.student_id=i.student_idif @student_id='0000000001' begin raiserror('不能插入1的學號!',16,8) rollback tran end go ]===============================================--update觸發器 create trigger tri_updateon studentfor update as if update(student_id)begin raiserror('學號不能修改!',16,8) rollback tran end go==================================--delete觸發器 create trigger tri_deleteon studentfor delete as declare @student_id varchar(10)select @student_id=student_id from deletedif @student_id='admin' begin raiserror('錯誤',16,8) rollback tran end================================================
標簽:
Sql Server
數據庫
排行榜