If this is really the path you want to go down, the code is all going to have to be dynamic. You can't do dynamic SQL within static SQL.

Why can't you just write regular static code using the actual table and column names, though?