我是靠谱客的博主 笨笨电脑,最近开发中收集的这篇文章主要介绍触发器新增、修改、删除,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

/****** Object:  Trigger [dbo].[trigger_Insert_ProjectItem]   ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--工程表插入触发器
ALTER trigger [dbo].[trigger_Insert_ProjectItem]
on [dbo].[ProjectItem] 
after insert
as 
insert into [Log_ProjectItem](GCID, XMID, GCMC, XMMC, JZMJ, GCFL1, GCFL2, GCFL3, SYXZ, SHDXNR, Address, JGLX, JCLX, DSCS, 
                DXCS, DSMJ, DXMJ, GCZJ, JHKGRQ, JHJGRQ, SGDW, SGDWZZZ, SGDWXMJL, XMJLJBZ, KCDW, KCDWZZZ, 
                XMKCFZR, XMKCFZRZCZGZH, SJDW, SJDWZZZ, XMJZSJFZR, XMJZSJFZRZCZGZH, XMJGSJFZR, 
                XMJGSJFZRZCZGZH, JLDW, JLDWZZZSH, JLS, JLSZCJGZH, QualifiedBook, NoticeAndContract, PersonnelList, 
                OtherFiles, JSDW, JSDWFDDB, JSDWXMFZR, JSDWFZRTEL, BBRQ, JDZSHYJ, XXJD, SHZTID, SHZT, IsTempSave, 
                ZJY, ZJYMC, SHR, SHRQ, CJRQ, XGRQ, CJR, CGR, BYID, SGDWTel, JSDWTel, JLDWTel, IsJunGong, IsGet, RegisterNo, 
                SerialNumber, Lon, Lat, ZJY2, ZJY2MC, ZJY3, ZJY3MC, ZJY4, ZJY4MC, EngType, LXR, LXR_Tel,[IsVaild],[CreateType],[LogCreateTime])

select *,'insert',getdate() from inserted




/****** Object:  Trigger [dbo].[trigger_Update_ProjectItem]  ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--工程表修改触发器
ALTER trigger [dbo].[trigger_Update_ProjectItem]
on [dbo].[ProjectItem] 
after update
as 
insert into [Log_ProjectItem] (GCID, XMID, GCMC, XMMC, JZMJ, GCFL1, GCFL2, GCFL3, SYXZ, SHDXNR, Address, JGLX, JCLX, DSCS, 
                DXCS, DSMJ, DXMJ, GCZJ, JHKGRQ, JHJGRQ, SGDW, SGDWZZZ, SGDWXMJL, XMJLJBZ, KCDW, KCDWZZZ, 
                XMKCFZR, XMKCFZRZCZGZH, SJDW, SJDWZZZ, XMJZSJFZR, XMJZSJFZRZCZGZH, XMJGSJFZR, 
                XMJGSJFZRZCZGZH, JLDW, JLDWZZZSH, JLS, JLSZCJGZH, QualifiedBook, NoticeAndContract, PersonnelList, 
                OtherFiles, JSDW, JSDWFDDB, JSDWXMFZR, JSDWFZRTEL, BBRQ, JDZSHYJ, XXJD, SHZTID, SHZT, IsTempSave, 
                ZJY, ZJYMC, SHR, SHRQ, CJRQ, XGRQ, CJR, CGR, BYID, SGDWTel, JSDWTel, JLDWTel, IsJunGong, IsGet, RegisterNo, 
                SerialNumber, Lon, Lat, ZJY2, ZJY2MC, ZJY3, ZJY3MC, ZJY4, ZJY4MC, EngType, LXR, LXR_Tel,[IsVaild],[CreateType],[LogCreateTime])
select *,'update',getdate() from inserted


/****** Object:  Trigger [dbo].[trigger_Delete_ProjectItem]     ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--工程表删除触发器
ALTER trigger [dbo].[trigger_Delete_ProjectItem]
on [dbo].[ProjectItem] 
after delete
as 
insert into [Log_ProjectItem](GCID, XMID, GCMC, XMMC, JZMJ, GCFL1, GCFL2, GCFL3, SYXZ, SHDXNR, Address, JGLX, JCLX, DSCS, 
                DXCS, DSMJ, DXMJ, GCZJ, JHKGRQ, JHJGRQ, SGDW, SGDWZZZ, SGDWXMJL, XMJLJBZ, KCDW, KCDWZZZ, 
                XMKCFZR, XMKCFZRZCZGZH, SJDW, SJDWZZZ, XMJZSJFZR, XMJZSJFZRZCZGZH, XMJGSJFZR, 
                XMJGSJFZRZCZGZH, JLDW, JLDWZZZSH, JLS, JLSZCJGZH, QualifiedBook, NoticeAndContract, PersonnelList, 
                OtherFiles, JSDW, JSDWFDDB, JSDWXMFZR, JSDWFZRTEL, BBRQ, JDZSHYJ, XXJD, SHZTID, SHZT, IsTempSave, 
                ZJY, ZJYMC, SHR, SHRQ, CJRQ, XGRQ, CJR, CGR, BYID, SGDWTel, JSDWTel, JLDWTel, IsJunGong, IsGet, RegisterNo, 
                SerialNumber, Lon, Lat, ZJY2, ZJY2MC, ZJY3, ZJY3MC, ZJY4, ZJY4MC, EngType, LXR, LXR_Tel,[IsVaild],[CreateType],[LogCreateTime])
select *,'delete',getdate() from deleted


最后

以上就是笨笨电脑为你收集整理的触发器新增、修改、删除的全部内容,希望文章能够帮你解决触发器新增、修改、删除所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(54)

评论列表共有 0 条评论

立即
投稿
返回
顶部