It is possible to query temp tables. You can create temp tables as simple as select * into #foo2 from foo where foobar = 'xxx'. Now your temp table #foo2 contains only foobar's = 'xxx'. ##Tablename are global. I will leave it to you to figure out how long a temp table persists.
Jason