Find the column names of Temp table

Pரதீப் picture Pரதீப் · May 29, 2015 · Viewed 15.3k times · Source

I need to find the column names of temp table.

If it is a physical table then we can either use sys.columns or Information_schema.columns system views to find the column names.

Similarly is there a way to find the column names present in temp table?

Answer

William Xifaras picture William Xifaras · May 29, 2015
SELECT *
FROM   tempdb.sys.columns
WHERE  object_id = Object_id('tempdb..#sometemptable');