I am having a problem getting this to do what I want... First problem, I cannot seem to get the procedure to take a query as an argument in parenthesis as stated.
To test, I just wrapped 'Table1' with '(SELECT * FROM Table1)'
-- Incorrect syntax near ')'.
The second problem is more complex and I will post another reply.