Advertisement

09.23.2007 at 08:26PM PDT, ID: 22847558
[x]
Attachment Details

Difference between "Temporary Table" and "Table Variable" in SQL Server 2000 / 2005 !!

Asked by kishore_peddi in SQL Server 2005, MS SQL Server, SQL Server 2008

Tags: table, sql, temporary, difference, between

Hi,

I have got these two concepts from online in SQL Server 2000 / 2005 - Difference between "Temporary Table" and "Table Variable". Can you please correct me if i am wrong / and please explain if necessary ?

Temporary Table
=============

1. If it is created within an SP or Trigger it is automatically destroyed when the creating routine terminates. If it is NOT created within SP or Trigger then we have to explicitly drop the table using "Drop Table #table" command.

2. It has more locking than table variable. // Can you please explain why ?

3. It has more logging than table variable. // Can you please explain why ?

Table Variable
===========

1. A table variable is automatically cleared when an SP, Trigger or UDF goes out of scope - Just like any other local variable. And we need not remember to drop or clear the data even though they are NOT created within an SP, Trigger or UDF.

2. It has less locking than temporary table.

3. It has less logging than temporary table.

Appreciate your time and patience !!

ThanksStart Free Trial
 
Loading Advertisement...
 
[+][-]09.23.2007 at 08:41PM PDT, ID: 19946441

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09.23.2007 at 09:27PM PDT, ID: 19946539

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SQL Server 2005, MS SQL Server, SQL Server 2008
Tags: table, sql, temporary, difference, between
Sign Up Now!
Solution Provided By: aneeshattingal
Participating Experts: 6
Solution Grade: A
 
 
[+][-]09.23.2007 at 11:51PM PDT, ID: 19946822

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09.24.2007 at 02:25AM PDT, ID: 19947179

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09.24.2007 at 02:47AM PDT, ID: 19947232

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09.26.2007 at 04:35AM PDT, ID: 19962059

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_1_20070628