常用触发器

一.插入时

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

ALTER? TRIGGER [insertReply] ON [dbo].[BBS_Reply]
FOR INSERT
AS
declare @post_id? int
select @post_id = post_id from inserted
--
update BBS_Post
set replay_times=replay_times+1
where post_id = @post_id
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

?

二.删除时

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO


ALTER?? TRIGGER [deleteReply] ON [dbo].[BBS_Reply]
FOR? DELETE
AS
declare @post_id int
select @post_id = post_id from deleted
--
update BBS_Post set replay_times = replay_times-1
where post_id = @post_id

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

?

posted @ 2005-03-26 01:06  meteorcui  阅读(337)  评论(0编辑  收藏  举报