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