HOW TO CREATE LOCAL TEMPORARY TABLE IN SQLSERVER.

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
 610  View(s)
Ratings:
Rate this:
Can anyone please help me how to solve this problem.
  1. aditya kumar Patel

    Post:254

    Points:1810
    Re: How to create temporary table in Sqlserver.

    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

      Modified On Oct-30-2015 03:02:32 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!