Temporary Table: Temporary tables, are very similar to the permanent tables. Permanent tables get created in the database you specify, and remain in the database permanently until you delete(drop) them. On the other hand, temporary tables get created in the TempDB and are automatically deleted, when they are no longer used.
Different Type of Temporary tables:
- Local Temporary tables using #
- Global Temporary tables using ##
Now Insert Stored Procedure output into Temporary Table:
/*CREATE PROCEDURE*/ CREATE PROCEDURE GetTemporaryTable AS BEGIN CREATE TABLE #Persons ( #Id int, #Name varchar(250), ); insert into #Persons values(1,'Jesy') END EXEC [dbo].[GetTemporaryTable]
In this stored procedure create a temporary table name as #Persons then insert value into table.