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 |
benildusmuerling
Yak Posting Veteran
81 Posts |
Posted - 2012-06-22 : 01:25:22
|
Hi All,Geeks thanks for reading my post, can anyone tell me which temp tables are good to use, in response to the increase in performance.would it be the temp tables called the table variables starting with '@' or other temp tables called the #temptablesThanks,AB |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-06-22 : 07:27:35
|
The ones that start with @ are TABLE VARIABLEs and the ones that start with # (or ##) are TEMP TABLES. You will see a lot of articles that discuss the pluses and minuses of each in-depth if you google using that terminology.To start with, temp tables can be indexed, table variables cannot. Temp tables cannot be used in UDFs, table variables can be. etc. etc. etc.Edit: I didn't read the original post carefully, or I would not have replied!! quote: Geeks thanks for reading my post
|
|
|
benildusmuerling
Yak Posting Veteran
81 Posts |
Posted - 2012-06-25 : 21:08:02
|
Thanks for the comment..reallyhelpful |
|
|
xhostx
Constraint Violating Yak Guru
277 Posts |
Posted - 2012-06-27 : 11:49:18
|
quote: Originally posted by benildusmuerling Hi All,Geeks thanks for reading my post, can anyone tell me which temp tables are good to use, in response to the increase in performance.would it be the temp tables called the table variables starting with '@' or other temp tables called the #temptablesThanks,AB
It is always up too what your needs are. I just want to add something to what sunitabeck said; you can still use a physical table during the run time of your script and you can call it a temporary table.defined Temporary tables you usally find them in tempdb like any other database instance in SQL Server.Luck,--------------------------Get rich or die trying-------------------------- |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-06-27 : 11:59:05
|
As a general rule - use temp tables for large things, table variables for small things.Often it's easier to develop larger processes using temp tables as they persist and you can follow the data through the statements.For smaller processes it's easier to use table variables as you don't have to keep droppping the temp tables.Usually it's only important to differentiate if you are running things many times a minute.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
|
|
|
|
|