MS-SMS里创建触发器:
首先右击表内的触发器文件夹图标
然后输入触发器创建指令,一下案例:(添加创建时间)
创建:
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= CREATE TRIGGER [dbo].[trigger_gfsbj] ON [dbo].[product] FOR INSERT AS BEGIN update o_product set pro_itime = getdate() from o_product as d inner join inserted as i on d.id=i.id END GO
创建后:
USE [GFSBJ] GO /****** Object: Trigger [dbo].[trigger_gfsbj] Script Date: 05/08/2016 13:04:21 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= ALTER TRIGGER [dbo].[trigger_gfsbj] ON [dbo].[product] FOR INSERT AS BEGIN update o_product set pro_itime = getdate() from o_product as d inner join inserted as i on d.id=i.id END
时间: 2024-10-02 23:40:44