Dynamic SQL has a bad reputation. When I started as a DBA I had a code quality checklist that had dynamic SQL on it as a problem. I later wrote a policy that said that dynamic object creation was forbidden. I’ve learned better since. If you’re going to perform the same operation on a number of different tables, generating the code is the only sensible option. Otherwise you’re repeating yourself, which is a far worse practise.
Read the rest on the Optimal BI blog.