-- Drop a temporary table called '#TableName'
-- Drop the table if it already exists
IF OBJECT_ID('tempDB..#TableName', 'U') IS NOT NULL
DROP TABLE #TableName
GO
-- Create the temporary table from a physical table called 'TableName' in schema 'dbo' in database 'DatabaseName'
SELECT *
INTO #TableName
FROM [DatabaseName].[dbo].[TableName]
WHERE /* add search conditions here */