I have just found the stored procedure here: http://www.wesnetdesigns.com/Downloads/tabid/76/Default.aspx
And here it is for others...
/********************************** Corrections for DNN 4.02.02 SQL Scripts *******************************/
if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}GetList]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure {databaseOwner}[{objectQualifier}GetList] GO
CREATE procedure {databaseOwner}{objectQualifier}GetList @ListName nvarchar(50), @ParentKey nvarchar(150), @DefinitionID int AS
If @ParentKey = '' Begin Select DISTINCT E.[ListName], E.[Level], E.[DefinitionID], E.[ParentID], (SELECT MAX([SortOrder]) FROM {objectQualifier}Lists WHERE [ListName] = E.[ListName]) As [MaxSortOrder], (SELECT COUNT(EntryID) FROM {objectQualifier}Lists WHERE [ListName] = E.[ListName] AND ParentID = E.[ParentID]) As EntryCount, IsNull((SELECT [ListName] + '.' + [Value] + ':' FROM {objectQualifier}Lists WHERE [EntryID] = E.[ParentID]), '') + E.[ListName] As [Key], IsNull((SELECT [ListName] + '.' + [Text] + ':' FROM {objectQualifier}Lists WHERE [EntryID] = E.[ParentID]), '') + E.[ListName] As [DisplayName], IsNull((SELECT [ListName] + '.' + [Value] FROM {objectQualifier}Lists WHERE [EntryID] = E.[ParentID]), '') As [ParentKey], IsNull((SELECT [ListName] + '.' + [Text] FROM {objectQualifier}Lists WHERE [EntryID] = E.[ParentID]), '') As [Parent], IsNull((SELECT [ListName] FROM {objectQualifier}Lists WHERE [EntryID] = E.[ParentID]),'') As [ParentList] From {objectQualifier}Lists E (nolock) where ([ListName] = @ListName or @ListName='') and (DefinitionID = @DefinitionID or @DefinitionID = -1) Order By E.[Level], [DisplayName] End Else Begin
DECLARE @ParentListName nvarchar(50) DECLARE @ParentValue nvarchar(100) SET @ParentListName = LEFT(@ParentKey, CHARINDEX( '.', @ParentKey) - 1) SET @ParentValue = RIGHT(@ParentKey, LEN(@ParentKey) - CHARINDEX( '.', @ParentKey)) Select DISTINCT E.[ListName], E.[Level], E.[DefinitionID], E.[ParentID], (SELECT MAX([SortOrder]) FROM {objectQualifier}Lists WHERE [ListName] = E.[ListName]) As [MaxSortOrder], (SELECT COUNT(EntryID) FROM {objectQualifier}Lists WHERE [ListName] = E.[ListName] AND ParentID = E.[ParentID]) As EntryCount, IsNull((SELECT [ListName] + '.' + [Value] + ':' FROM {objectQualifier}Lists WHERE [EntryID] = E.[ParentID]), '') + E.[ListName] As [Key], IsNull((SELECT [ListName] + '.' + [Text] + ':' FROM {objectQualifier}Lists WHERE [EntryID] = E.[ParentID]), '') + E.[ListName] As [DisplayName], IsNull((SELECT [ListName] + '.' + [Value] FROM {objectQualifier}Lists WHERE [EntryID] = E.[ParentID]), '') As [ParentKey], IsNull((SELECT [ListName] + '.' + [Text] FROM {objectQualifier}Lists WHERE [EntryID] = E.[ParentID]), '') As [Parent], IsNull((SELECT [ListName] FROM {objectQualifier}Lists WHERE [EntryID] = E.[ParentID]),'') As [ParentList] From {objectQualifier}Lists E (nolock) where [ListName] = @ListName And [ParentID] = (SELECT [EntryID] From {objectQualifier}Lists Where [ListName] = @ParentListName And [Value] = @ParentValue) Order By E.[Level], [DisplayName]
End GO
Geoffrey Morton-Haworth
www.yalaworld.net
|