-- ============================================= -- Author: -- Create date: -- Description: -- ============================================= CREATE PROCEDURE [dbo].[sp_getTVElements] @idReport as int AS BEGIN SET NOCOUNT ON; SELECT [IdSezione] ,[Descrizione] ,[DtCancellazione] ,[IdSezionePadre] ,[DtCreazione] ,[Nome] ,[FlgSezione] ,[ClasseRealizzazione] ,[IdReport] ,[TpSezione] ,[Utente] ,[Ordine] ,[TpInclusione] ,[ClasseVisualizzazione] ,[NomeControlloGruppo] ,[IsDefault] ,[IsMandatory] ,[internalSectionCode] ,[IsBold] ,(select count(*) FROM [dbo].[Sezione] WHERE [IdSezionePadre]=sc.[IdSezione]) childnodecount FROM [dbo].[Sezione] sc WHERE [IdSezionePadre] is NULL AND IdReport = @idReport ORDER BY [Ordine] END