Sunday 4 May 2014

Diffence between Table Variable and Temp Table



#.
Table Variable
Temp Table
1
It stored in primary memory(ie. in RAM)
It stored in system database(ie. In msdb)
2
It has batch scope only, ie. Till the current t-sql stmt to be execute
It has the scope till the query window close, In case of local temp table and has the scope till all the SSMS query windows close in case of global temp table
3
Table variables can’t use within select into clause
Temp tables can be used within select into clause
4
Table variables gives better performance than temp table, because they stores in primary memory (ie. In RAM)
Temp tables not gives better performance than table variables, because it stores in hard disk
5
We can’t explicitly drop the table variables
We can explicitly drop the temp tables

No comments:

Post a Comment