Stored Procedure Icon dbo.forums_GetAllForumGroups

Stored Procedure Properties

Name Value
Owner dbo
Created 2004-05-31
Startup False
Encrypted False

Creation Options

Name Value
QUOTED_IDENTIFIER ON
ANSI_NULLS ON

Parameters

Name DataType Length Type
@GetAllForumsGroups bit 1 INPUT
@UserName nvarchar 100 INPUT

Total: 2 parameter(s)

SQL

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO




CREATE          PROCEDURE forums_GetAllForumGroups
(
	@GetAllForumsGroups	bit = 0,
	@UserName nvarchar(50)
)
AS
BEGIN
	IF @GetAllForumsGroups = 0

		IF @UserName IS NOT NULL
		BEGIN
			SELECT 
				ForumGroupId,
				Name,
				SortOrder
			FROM
				ForumGroups
			WHERE
				EXISTS(
					SELECT
						ForumID
					FROM
						FORUMS
					WHERE
						ForumGroups.ForumGroupID = Forums.ForumGroupId AND
						Forums.Active = 1 AND
						(ForumID NOT IN (SELECT ForumID from PrivateForums) OR
						ForumID IN (SELECT ForumID FROM PrivateForums WHERE RoleName IN (SELECT RoleName from UsersInRoles WHERE username = @UserName)))

				)
		END
		ELSE
		BEGIN
			SELECT 
				ForumGroupId,
				Name,
				SortOrder
			FROM
				ForumGroups
			WHERE
				EXISTS(
					SELECT
						ForumID
					FROM
						FORUMS
					WHERE
						ForumGroups.ForumGroupID = Forums.ForumGroupId AND
						Forums.Active = 1 AND
						ForumID NOT IN (SELECT ForumID from PrivateForums)
				)
		END
	ELSE
		SELECT 
			ForumGroupId,
			Name,
			SortOrder
		FROM
			ForumGroups
			
END










GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO


					

Generated on 26/08/2004 15:05:27 by DataAide.