AS SELECT DISTINCT TOP 100 PERCENT 
Variables_1.VarID, 
Statements.Description AS StatementType, 
Programs_1.ProgramID, 
pgma1.AliasName, 
Paths.PathStr, 
OccurrencesStmt.StartRow,
Programs_2.ProgramID,
Programs_2.AliasName,
Variables_1.VarName
FROM ((((Programs AS Programs_1
INNER JOIN ProgramAliases pgma1 ON pgma1.ProgramId = Programs_1.ProgramID and pgma1.AliasType = 0 
INNER JOIN StatementReference AS StatementReference_2 ON Programs_1.ProgramID = StatementReference_2.ResourceID) INNER JOIN (((Statements INNER JOIN OccurrencesStmt ON Statements.StatementType = OccurrencesStmt.StatementType) INNER JOIN ProgramAliases AS Programs_2 ON OccurrencesStmt.ProgID = Programs_2.ProgramID and Programs_2.AliasType = 0) INNER JOIN (StatementReference AS StatementReference_1 INNER JOIN Variables AS Variables_1 ON StatementReference_1.ResourceID = Variables_1.VarID) ON OccurrencesStmt.OccurID = StatementReference_1.OccurID) ON StatementReference_2.OccurID = OccurrencesStmt.OccurID) INNER JOIN StatementReference AS StatementReference_3 ON OccurrencesStmt.OccurID = StatementReference_3.OccurID) INNER JOIN CallParameters ON (Variables_1.VarID = CallParameters.VariableId) AND (StatementReference_3.ResourceID = CallParameters.ID)) INNER JOIN Paths ON OccurrencesStmt.PathID = Paths.PathID
WHERE 
	(((Variables_1.VarID) In (Select * from #numeric_param_temp)) 
	AND ((StatementReference_2.ResourceType)=5) AND ((StatementReference_1.ResourceType)=4) AND ((StatementReference_3.ResourceType)=96) AND ((Programs_1.ProgramTypeID)>=0))
ORDER BY Variables_1.VarID;
