bbs论坛插入帖子时的存储过程
SET NOCOUNT on;不返回影响行数提高性能
GO
create proc [sp_bbs_thread_Insert]
@id int output,
@title varchar(255),@content text, @userid int, @typeid int,
@catalogid int........许多参数
SELECT @id = SCOPE_IDENTITY();
while(1=1)
begin
update bbs_catalog set threadCount=threadCount+1,lastThreadId=@id where id=@catalogid
select @catalogid=parentId from bbs_catalog where Id=@catalogid
if(@catalogid=0)
break;
end
循环使此版块和它的父板块threadCount的发帖数量加1直到没有父板块
板块表的列
id name parentId,lastthreadId,threadCount