Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15694

Finding out which #tables in temporary db belong to which session_id?

$
0
0

Is it possible to finding out which #tables in temporary db belong to which session_id.

I would like to link the name of the temp objects (#temp tables, ##temp tables, and #[0-F][0-F][0-F][0-F][0-F][0-F][0-F][0-F] table variables etc) to the sessions they linked. I was able to get some part of this querying the default profile for tempdb for object created event but I only get a small tables linked, I want to be able to link them all.

Thank you

SELECT name, object_id FROM tempdb.sys.tables


SELECT
	[name], CAST([object_id] AS INT) AS [object_id]
FROM (VALUES('#A016ED6A', '-1609110166'),
	('#A02495A0', '-1608215136'),
	('#A031727F', '-1607372161'),
	('#A0323DD6', '-1607320106'),
	('#A0394B00', '-1606857984'),
	('#A03A6F90', '-1606783088'),
	('#A03B3AE7', '-1606731033'),
	('#A03F1AB5', '-1606477131'),
	('#dbsize_____________________________________________________________________________________________________________000000000E25', '-1553389896'),
	('##Sessions_20130104_164253660', '661577395'),
	('##TablesInTempdb_20130104_164253660', '677577452'),
	('##DatabaseFiles_20130104_164253660', '693577509'),
	('##Sessions_20130104_164302367', '709577566'),
	('##TablesInTempdb_20130104_164302367', '725577623'),
	('##DatabaseFiles_20130104_164302367', '741577680'),
	('##Sessions_20130104_164716683', '757577737'),
	('##TablesInTempdb_20130104_164716683', '773577794'),
	('##DatabaseFiles_20130104_164716683', '789577851'),
	('##Sessions_20130104_164832617', '805577908'),
	('##TablesInTempdb_20130104_164832617', '821577965'),
	('##DatabaseFiles_20130104_164832617', '837578022'),
	('##Sessions_20130104_164844060', '853578079'),
	('##TablesInTempdb_20130104_164844060', '869578136'),
	('##DatabaseFiles_20130104_164844060', '885578193'),
	('##Sessions_20130104_171059763', '901578250'),
	('##TablesInTempdb_20130104_171059763', '917578307'),
	('##DatabaseFiles_20130104_171059763', '933578364'),
	('##Sessions_20130105_051035670', '949578421'),
	('##TablesInTempdb_20130105_051035670', '965578478'),
	('##DatabaseFiles_20130105_051035670', '981578535'),
	('##Sessions_20130105_051335187', '997578592'),
	('##TablesInTempdb_20130105_051335187', '1013578649'),
	('##DatabaseFiles_20130105_051335187', '1029578706'))
d ([name], [object_id])

name                                                                                                                            object_id
-------------------------------------------------------------------------------------------------------------------------------- -----------
#A016ED6A                                                                                                                       -1609110166
#A02495A0                                                                                                                       -1608215136
#A031727F                                                                                                                       -1607372161
#A0323DD6                                                                                                                       -1607320106
#A0394B00                                                                                                                       -1606857984
#A03A6F90                                                                                                                       -1606783088
#A03B3AE7                                                                                                                       -1606731033
#A03F1AB5                                                                                                                       -1606477131
#dbsize_____________________________________________________________________________________________________________000000000E25 -1553389896
##Sessions_20130104_164253660                                                                                                   661577395
##TablesInTempdb_20130104_164253660                                                                                             677577452
##DatabaseFiles_20130104_164253660                                                                                              693577509
##Sessions_20130104_164302367                                                                                                   709577566
##TablesInTempdb_20130104_164302367                                                                                             725577623
##DatabaseFiles_20130104_164302367                                                                                              741577680
##Sessions_20130104_164716683                                                                                                   757577737
##TablesInTempdb_20130104_164716683                                                                                             773577794
##DatabaseFiles_20130104_164716683                                                                                              789577851
##Sessions_20130104_164832617                                                                                                   805577908
##TablesInTempdb_20130104_164832617                                                                                             821577965



Gokhan Varol


Viewing all articles
Browse latest Browse all 15694

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>