I am creating a temporary table on-the-fly using Select * Into #temp from SomeChangingSource
in a stored procedure. I need to then list the resulting columns.
Handling this for a regular (permanent) table is as simple as:
select COLUMN_NAME
from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME='TableName'
How do I handle this for a temporary table?
Your were close. Just needed to point it to Tempdb.Sys.Columns
Select * From Tempdb.Sys.Columns Where Object_ID = Object_ID('tempdb..#TempTable')