Hi
How can you define Local Temporary Table and Global Temporary Table in SQL Server ?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Jul 9, 2012, 7:20 AM
Please refer the below links
http://www.codeproject.com/Articles/42553/Quick-Overview-Temporary-Tables-in-SQL-Server-2005
http://www.varindersandhu.in/2011/06/05/sql-server-local-temporary-table-vs-global-temporary-table/
Thanks
Jignesh TrivediPosted Jul 9, 2012, 6:31 AM
A temporary table is created and populated on disk, in the system database tempdb — with a session-specific identifier packed onto the name, to differentiate between similarly-named #temp tables created from other sessions. The data in this #temp table (in fact, the table itself) is visible only to the current scope
CREATE TABLE #people
(
PeoPleId INT,
Name VARCHAR(32)
)
Global temporary tables operate much like local temporary tables; they are created in tempdb and cause less locking and logging than permanent tables. However, they are visible to all sessions, until the creating session goes out of scope
CREATE TABLE ##people
(
PeoPleId INT,
Name VARCHAR(32)
)
hope this will help you.
Posted Jul 9, 2012, 6:08 AM
For local temp table.
create table #temp1
(your table details)
For global temp table
create table ##temp2
(your table details)