Create temporary table in sqlserver
You'll notice I prefixed the table with a pound sign (#). This tells SQL Server that this table is a local temporary table. This table is only visible to this session of SQL Server. When I close this session, the table will be automatically dropped. You can treat this table just like any other table with a few exceptions. The only real major one is that you can't have foreign key constraints on a temporary table.
CREATE TABLE #Books (
BookID int,
BookName char(30) )
select BookName
from tempdb..sysobjects
where name like '#Books%'
drop table #Books