Stored Procedure Properties
Name | Value |
---|---|
Owner | dbo |
Created | 2004-05-31 |
Startup | False |
Encrypted | False |
Creation Options
Name | Value |
---|---|
QUOTED_IDENTIFIER | OFF |
ANSI_NULLS | OFF |
Parameters
Name | DataType | Length | Type |
---|---|---|---|
@PostID | int | 4 | INPUT |
Total: 1 parameter(s)
SQL
SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS OFF GO CREATE PROCEDURE forums_DeletePost ( @PostID int ) AS -- we must delete all of the posts and replies -- first things first, determine if this is the parent of the thread DECLARE @ThreadID int DECLARE @ForumID int DECLARE @UserName nvarchar(50) SELECT @ThreadID = ThreadID, @ForumID = ForumID, @UserName = Username FROM Posts (nolock) WHERE PostID = @PostID IF @ThreadID = @PostID BEGIN -- we are dealing with the parent fo the thread -- delete all of the thread tracking DELETE FROM ThreadTrackings WHERE ThreadID = @ThreadID -- delete the entire thread DELETE FROM Posts WHERE ThreadID = @ThreadID -- Update the forum statistics exec Statistics_ResetForumStatistics @ForumID END ELSE -- we must recursively delete this post and all of its children exec dbo.forums_DeletePostAndChildren @PostID GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO