@filter VARCHAR(200) AS SELECT
	pa.ProgramName, 
	Paragraphs.ParaName AS [Procedure Name], 
	Paths.PathStr AS [Source File Name],
	Resources.Name AS [Include Name], 
	Occurrences.StartRow AS Line, 
	Paragraphs.NumOfStatements AS NumOfStmts
FROM dbo.Occurrences AS Occurrences_1 INNER JOIN
     dbo.Resources ON Occurrences_1.OccurID = dbo.Resources.OccurID 
     RIGHT OUTER JOIN dbo.Paragraphs INNER JOIN 
	 (SELECT Programs.ProgramID, Programs.ProgramTypeID, ProgramAliases.AliasName AS ProgramName  FROM dbo.Programs 
					INNER JOIN ProgramAliases ON ProgramAliases.ProgramId = Programs.ProgramID and ProgramAliases.AliasType = 0) pa 
     ON dbo.Paragraphs.ProgramID = pa.ProgramID 
     INNER JOIN dbo.Occurrences ON dbo.Paragraphs.OccurID = dbo.Occurrences.OccurID 
     INNER JOIN dbo.Paths ON dbo.Occurrences.PathID = dbo.Paths.PathID
      ON Occurrences_1.PathID = dbo.Paths.PathID
WHERE (dbo.Paragraphs.UnreachablePara = - 1) AND (pa.ProgramTypeID = 1)
     AND(( @filter='0' AND Paragraphs.IsExitPara<>-1) OR (@filter='1'))
     AND Paragraphs.ParaName NOT LIKE 'IDMS-STATUS_%'
     AND Paragraphs.ParaName NOT LIKE 'IDMS-ABORT_%'
     AND Paragraphs.ParaName NOT LIKE 'IDMS-STATISTICS_%'
     AND (pa.ProgramID in (Select * from #numeric_param_temp))
ORDER BY pa.ProgramName, Resources.Name,Paragraphs.ParaName 