Well, there may be more problems down this path than perhaps is apparent.
What you're looking at is extensive use of dynamic SQL. This is a real Pandoras Box.
In order to get some insight on what's ahead, please do read this article.
http://sommarskog.se/dynamic_sql.html
/Kenneth