Hi Can somebody explain me the difference between Temp table and table variable in SQL server 2005?
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
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.
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.
This is a good article on SQL Server Central detailing the differences and limitations of each.