T-SQL: Describe a temp table with sp_help

If you are looking to verify the structure of a temp table you have created within a SQL query batch, you can use sp_help to describe the table.

SELECT Top 1 * 
INTO #MyTempTable
FROM dbo.SomeTable
 
EXEC tempdb.dbo.sp_help N'#MyTempTable'
 
DROP TABLE #MyTempTable
The results of sp_help for the example temp table

The results of sp_help for the example temp table

This entry was posted in MS SQL Server, T-SQL. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *