Learning Horizon | For Learners

ASP.NET, SQL SERVER, JQUERY,JAVASCRIPT, WEBSPHERE

Monday 22 April 2013

Difference Between Local And Global Temporary Tables

In this tutorial we will learn about local and global temporary tables in MicroSoft Sql Server. Temporary table are very handy when you need to process data or perform calculation using same selection. They are also very useful when you need data temporarily because when client session disconnet they vanishes away. There are two type of temporary tables and below are the details of each type.

Local Temporary Table:-


To create local temporary table we use below statement.

                        create table # temp

Now this table is only visible to connection(same query window) that creates it.And it will be deleted when the connection(query window) will be closed. local temporary tables cannot be shared between multiple users.All temp tables are stored in tempdb database.

Global Temporary Table:-


To create Global temporary table we use below statement.

                        create table ## temp

Now this table is available to all connections and not cleared until unless the last connection is closed. These tables can be shared to multiple users as well and they are also stored in tempdb database.

No comments:

Post a Comment

Please do not enter spam links.