Currently, I have some temp tables as this format "#A0089D2C", "#A0232241"
How could I select them to see what are its data?
I tried these queries as below:
Select * from #A0089D2C
Select * from tempdb.dbo.#A0089D2C
But I got the error:
Database name 'tempdb' ignored, referencing object in tempdb.
Database name 'tempdb' ignored, referencing object in tempdb.
Msg 208, Level 16, State 0, Line 1
Invalid object name '#A0089D2C'.
Please advise.
Thanks.
Technically, only that user who created the local temporary table can access it within the scope. That means, local temporary table (# tables) can be accessed within the same scope by the same user while global temporary table(## tables) can be accessed among all the users until the last user session that references the table disconnects.
you can check table schema via below trick:
but if you are really enthusiastic to see data in temporary table then check out this awesome post about viewing another session's Temporary table by Paul White