首页 > 数据库 > SQL Server > 正文

SQL Server论坛楼层计算触发器

2024-08-31 00:54:21
字体:
来源:转载
供稿:网友
SQL Server论坛楼层计算触发器

代码:

USE suya_devGOIF EXISTS(    SELECT *    FROM sys.triggers    WHERE name = N'BBS_Post_before_insert')    DROP TRIGGER BBS_Post_before_insert GOCREATE TRIGGER BBS_Post_before_insert     ON BBS_Post    FOR insertAS 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=@IdENDGO
View Code


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表