码迷,mamicode.com
首页 > 数据库 > 详细

mssql 创建触发器

时间:2016-05-08 13:47:15      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:

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

 

mssql 创建触发器

标签:

原文地址:http://www.cnblogs.com/swack/p/5470407.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!