Ken,
When you use Dynamic SQL, it is treated as a seperate batch. Variables and temporary tables are removed when the batch is completed.
You do have a couple of options though. You can follow Stephen's suggestion of calling a stored procedure or you can create the temporary table before calling the dynamic sql.
-Mike