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.


#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

| improve this answer | |
  • 1
    I'm definitely not looking to use in production code, but rather something I can easily use to debug a specific issue in a specific edge case I'm in. It'll likely be a one time use. – J.D. Dec 11 '19 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.