CREATE PROCEDURE [dbo].[sp_getTVElements_byParentID] @pID as int, @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]=@pID and IdReport=@idReport ORDER BY [Ordine] END