Fix SQL statements that have dynamic table names to use proper syntax.