RSS订阅优然探索
你的位置:首页 » 技术文章 » 正文

触发器01

选择字号: 超大 标准 发布时间:2009-8-24 1:58:8 | 作者:admin | 0个评论 | 人浏览

USE [CAprj]
GO
/****** Object:  Trigger [dbo].[TB_LogInfo_Delete]    Script Date: 08/24/2009 16:57:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:  <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER TRIGGER [dbo].[TB_LogInfo_Delete]
   ON  [dbo].[TB_LogInfo]
   For Delete
AS
declare
@ID int,
@SourceID nvarchar(max),
@ModuleID nvarchar(max),
@TypeID nvarchar(max),
@KeyID nvarchar(max),
@DetailDescription nvarchar(max),
@CreateDate nvarchar(max),
@CreateBy nvarchar(max)
BEGIN
 -- SET NOCOUNT ON added to prevent extra result sets from
 -- interfering with SELECT statements.
 SET NOCOUNT ON;
 if EXISTS(SELECT 1 FROM deleted)
  begin
  select @ID=ID,
  @SourceID=SourceID,
  @ModuleID=ModuleID,
  @TypeID=TypeID,
  @KeyID=KeyID,
  @DetailDescription=DetailDescription,
  @CreateDate=CreateDate,
  @CreateBy=CreateBy
  from deleted
 
  insert into TB_LogInfo_Bak(ID,SourceID,ModuleID,TypeID,KeyID,DetailDescription,CreateDate,CreateBy)
  values(@ID,@SourceID,@ModuleID,@TypeID,@KeyID,@DetailDescription,@CreateDate,@CreateBy)
 end
END
 

标签:TRigger  

猜你喜欢

发表评论

必填

选填

选填

必填,不填不让过哦,嘻嘻。

记住我,下次回复时不用重新输入个人信息

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。