SQL Server论坛楼层计算触发器
代码:
USE suya_dev GO IF EXISTS( SELECT * FROM sys.triggers WHERE name = N‘BBS_Post_before_insert‘ ) DROP TRIGGER BBS_Post_before_insert GO CREATE TRIGGER BBS_Post_before_insert ON BBS_Post FOR insert AS BEGIN declare @Id int declare @TopicId int declare @Floor int select @Id = Id from inserted select @TopicId = TopicId from inserted select @Floor = count(1) from BBS_Post where TopicId=@TopicId update BBS_Post set Floor=@Floor where Id=@Id END GO
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。