SQL server Function to select rows from multiple tables based : can anyone please help with this query ?

I’m using SQL server 2008 . Objective is to select  rows from multiple tables based on condition and values from different tables .

1) I have table1, table2, tableN with columns as ID,ColumnName,ColumnValue . These are the table I need to select rows based on conditions from below table
2) Control table with columns Number,Function and Enable 
2) Repository table with columns Function and tableName

I need pass Number and ID as parameters and get details of all Function values from Control table  which has Enable value = 1 and  by using  these Function values collect tableNames from Repository table . And for each tableName returned from Repository table get all rows by using ID value .

Appreciate any suggestions 