Populate Temp Table Before Running SQL Optimizer

Is there a way to run a sql statement that populates a temp table before the optimizers runs against a sql statement that queries said temp table...or alternately a way to make the optimizer run an existing instance where the temp table is already populated?

Based on what you've described,

  1. Can you get by with a CTE (common table expression)?
    e.g. using a WITH clause ...

  2. Can you populate the temp table up front, and then run your query optimization right after?

Otherwise, let the community know added details of what you're trying to accomplish.