SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[cs_Section_Get]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[cs_Section_Get]
GO



CREATE Procedure [dbo].cs_Section_Get
(
	@SettingsID int,
	@SectionID int,
	@ApplicationKey nvarchar(512) = null,
	@ApplicationType smallint
)

as
SET Transaction Isolation Level Read UNCOMMITTED

if(@ApplicationKey is not null)
Begin
	Select @SectionID = SectionID FROM cs_Sections where ApplicationKey = @ApplicationKey and ApplicationType = @ApplicationType
End

SELECT 
	SectionID, SettingsID, IsActive, ParentID, GroupID, [Name], NewsgroupName, [Description], 
	DateCreated, Url, IsModerated, DaysToView, SortOrder, TotalPosts, TotalThreads, DisplayMask, 
	EnablePostStatistics, EnablePostPoints, EnableAutoDelete, EnableAnonymousPosting, AutoDeleteThreshold, 
	MostRecentPostID, MostRecentThreadID, MostRecentThreadReplies, MostRecentPostSubject, 
	MostRecentPostAuthor, MostRecentPostAuthorID, MostRecentPostDate, PostsToModerate, ForumType, 
	IsSearchable, ApplicationType, ApplicationKey, PropertyNames as SectionPropertyNames, PropertyValues as SectionPropertyValues, Path, DefaultLanguage
FROM 
	cs_Sections 
Where SectionID = @SectionID and ApplicationType = @ApplicationType

exec cs_Section_Permissions_Get @SettingsID, @SectionID, @ApplicationType
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

GRANT  EXECUTE  ON [dbo].[cs_Section_Get]  TO [public]
GO

