常用触发器
一.插入时
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
?
                    
                
                
            
        
浙公网安备 33010602011771号