tempdb_id( [spid] )
Returns the database ID of the specified session’s temporary database; without spid, returns the ID of the temporary database for the current session.
Example
select DB_Name( tempdb_id() )