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 |
|---|---|---|---|
| @ForumID | int | 4 | INPUT |
| @PageSize | int | 4 | INPUT |
| @PageIndex | int | 4 | INPUT |
| @UserName | nvarchar | 100 | INPUT |
Total: 4 parameter(s)
SQL
SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS OFF GO CREATE PROCEDURE forums_GetAllUnmoderatedTopicsPaged ( @ForumID int, @PageSize int, @PageIndex int, @UserName nvarchar (50) ) AS DECLARE @PageLowerBound int DECLARE @PageUpperBound int -- Set the page bounds SET @PageLowerBound = @PageSize * @PageIndex SET @PageUpperBound = @PageLowerBound + @PageSize + 1 -- Create a temp table to store the select results CREATE TABLE #PageIndex ( IndexID int IDENTITY (1, 1) NOT NULL, PostID int, PostDate datetime ) BEGIN -- INSERT into the temp table INSERT INTO #PageIndex SELECT PostID, PinnedDate FROM POSTS P WHERE ForumID = @ForumID AND Approved = 0 ORDER BY PinnedDate DESC -- Now get the posts SELECT Subject, Body, P.PostID, ThreadID, ParentID, P.PostDate, ThreadDate, PinnedDate, UserName, Replies = (SELECT COUNT(*) FROM Posts WHERE P.ThreadID = ThreadID AND PostLevel != 1 AND Approved = 1), Body, TotalViews, IsLocked, IsPinned, HasRead = 0, MostRecentPostAuthor = '', MostRecentPostID = 0 FROM Posts P (nolock), #PageIndex PageIndex WHERE P.PostID = PageIndex.PostID AND PageIndex.IndexID > @PageLowerBound AND PageIndex.IndexID < @PageUpperBound ORDER BY PageIndex.IndexID END GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO