SQL Server provides the concept of temporary table which helps the developer in a best way. These tables can be created at runtime and can do the all kinds of operations that one normal table can do. But, based on the table types, the scope is limited. These tables are created inside tempdb database. Local temp tables are only available to the current connection for the user; and they are automatically deleted when the user disconnects from instances. Local temporary table name is stared with hash ("#") sign. --step 1 create local temporary table
CREATE TABLE #temptbl(
OrderID int,
Orderdate datetime,
amount decimal(10,2)
);
--step-2 insert data in #temptabl from order table
insert into #temptbl select * from [Order]
--step-3 select data from #temptabl
select * from #temptbl
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
--step 1 create local temporary table