Thursday, March 14, 2013

What are the types of temp tables in Ms SQL Server?

1. Local Temp Table
Table prefixed with a single hash (#) denotes a local temporary table available to the current connection for the user. It disappears when the user disconnects.

CREATE TABLE #tempLocal ( Uid int, Fname varchar(50), Lname varchar(50) )

2. Global Temp Table
Table prefixed with double hash (##) denotes a global temporary table available to all users via all connections. They are deleted only when all connections are closed.

CREATE TABLE ##tempGlobal ( Uid int, Fname varchar(50), Lname varchar(50) )

No comments :