HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Is there an easy way to SELECT FROM another session's temp table?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
tabletempwayeasyanothersessionselectfromthere

Problem

Is there an easy way to select the data from another session's temp table? I need to do so ad-hocly to debug an issue that I have limited visibility on otherwise.
E.g. if I have access to TEMPDB, is it possible to access the table object itself?

I saw this post from Paul White on one way to do it, but it's a lot more involved then I was hoping for: Viewing Another Session's Temporary Table

I cannot switch the code to use a global temp table for debugging purposes.

Solution

#temp is session scope

CREATE TABLE (Transact-SQL) - Temporary Tables

A local temporary table, #table_name, exists only for the duration of a user session or the procedure that created the temporary table.

Do the official microsoft way no tricks, it would end in a mess

Context

StackExchange Database Administrators Q#255345, answer score: 5

Revisions (0)

No revisions yet.