Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
itmaster
Starting Member
28 Posts |
Posted - 2015-01-29 : 10:57:29
|
Hi,Was recently asked, in an interview when should I use temp tables or temp Variables, and when should I not use them. I was not sure about this and was wondering if anyone could give a better answer then I had on this; which was not much, and I did not find a good answer on the web.Thank you |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2015-01-29 : 11:46:07
|
If the query is simple or the data set is small, table Variables are OK.The thing is SQL does not maintain stats for table variables, so it may unable to compute a good execution plan for a complex query (e.g. lots of joins with multiple predicates). However, if the dataset is small, this is usually not an issue. |
|
|
itmaster
Starting Member
28 Posts |
Posted - 2015-01-29 : 11:48:04
|
Thank you |
|
|
|
|
|