2

Can somebody explain me the difference between Temp table and table variable in SQL server 2005?

3
  • 1
    please try a search....there are numerous articles out there... Commented Jan 6, 2010 at 8:43
  • Thanks.. I ve searched and got lot of answers. Commented Jan 6, 2010 at 8:49
  • stackoverflow.com/questions/1597309/… Commented Jan 6, 2010 at 10:01

4 Answers 4

1

There are few differences you can check them here. There is a performance difference that favors table variables because temporary tables prevent precompilation of procedures. Also the scope of a table variable is the same as the scope of variables compared to temporary tables which have bigger lifespan. In general table variables are the better choice in most cases.

Sign up to request clarification or add additional context in comments.

Comments

0

Hope these helps:

http://databases.aspfaq.com/database/should-i-use-a-temp-table-or-a-table-variable.html http://www.sql-server-performance.com/articles/per/temp_tables_vs_variables_p1.aspx

Comments

0

fundamentally, temp table is written to disk until you call drop table and table variable lives in memory for the scope of the query.

Table variable is often said to be fast, but as this question of my highlight, this can be a complex subject.

1 Comment

This is a myth. See my answer here
0

This is a good article on SQL Server Central detailing the differences and limitations of each.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.