I don't think quotes is your problem.Your SET statement (which is missing one trailing ' ) generates this:SELECT("c.code") as custnum("mi.prospect") as prospectFROM Orders owhich is not valid in a number of ways.I think you are trying to reference c.code - but there is no table aliased as "c", similarly with mi.prospect there is no table alias "mi"If you need to surround the column names I recommend you use [...], rather than " quote, and you should not include the alias name inside the quotes/brackets:SELECT c.[code] as custnum mi.[prospect] as prospectFROM Orders o... Join other tables for C and MI aliases ...
You also need parenthesis around your EXEC statement, as konark said:EXEC ( @Sql_Statement )