I working with legacy (ancient is more appropriate word) application which use temp tables (#) to pass data between different stored procdures, temp tables are created in batches (not in stored procedures) so visibility of this table is per connection, scenario is as follows:
create table #temp …
run stored_procedure_1 – this one for instance inserts data into #temp
run stored_procedure_2 – this one for instance uses data inserted previously
Is there a way to read data from #temp using other connection ?
In anticipation of questions why I need this ? – application code is very difficult, to better understand what is going on in it, I am often attaching profiler and looking at queries which are sent into db, ability to looking what is inside temp tables created by app connection, would be helpful
No.
The
#temptables are specifically only for the current connection that created them.If you need globally visible temp tables, use the
##tempnotation (with two#at the beginning)