HOW TO CREATE GLOBAL TEMPORARY TABLE IN SQLSERVER.

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
 518  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 global 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. Global Temporary tables name starts with a double hash ("##"). Once this table has been created by a connection, like a permanent table it is then available to any user by any connection. It can only be deleted once all connections have been closed.

     --step 1 create global temporary table
    

    CREATE TABLE ##globaltemptbl

    (

     

    OrderID int, rderdate datetime,

    amount decimal(10,2)

    );

     

    --step-2 insert data in #globaltemptabl from order table

    insert into ##globaltemptbl select * from [Order]

    --step-3 select data from #globaltemptabl

    select * from ##globaltemptbl

      Modified On Oct-30-2015 03:04:21 AM

Answer

NEWSLETTER

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