创建Insert触发器
USE [appsmart]
GO
/****** Object: Trigger [dbo].[notify_trigger] Script Date: 01/25/2017 09:31:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
----------------创建触发器
ALTER TRIGGER [dbo].[notify_trigger] ON [dbo].[Table_Test]
AFTER INSERT
AS
BEGIN
DECLARE @userName NVARCHAR(20) --Insert触发器 下面为inserted相当于触发器的一个虚拟插入表
set @userName=(select inserted.userName from inserted)
EXEC testProPush @userName ---调用存储过程并传参 如果传入的参数未变则不会触发
END
创建存储过程
USE [appsmart]
GO
/****** Object: StoredProcedure [dbo].[testPro] Script Date: 01/25/2017 09:18:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[testPro](
@userName varchar(50)
)
AS
BEGIN