Temp Tables
Temp tables are tables you create per session or connection, once that connection or session ends the temp table is removed.
Create
SELECT *
INTO #MyTempTableName
FROM SchameName.TableName -- imagine you have done something more complexUse
SELECT *
FROM #MyTempTableNameBasically when ever you reference a temp table you must prefix with a #
Drop
You will likely need to drop temp tables before you use them, since there might be one lingering about.
DROP TABLE IF EXISTS #MyTempTableName
-- or for older versions
IF OBJECT_ID('tempdb..#MyTempTableName') IS NOT NULL
DROP TABLE #MyTempTableName