"Helmut Wöss" <h.woess (AT) iis-edv (DOT) at> wrote
Quote:
yes, table variables are faster than temp tables because they are
used like normal local variables, so no lockings are necessary
and they are not created in tempdb (only running in ram)
But there are some other points to take care:
- table variables are not included in transactions, so no rollback possible
- you can't do something like:
INSERT INTO table_variable EXEC stored_procedure
SELECT select_list INTO table_variable statements
- and you can't use them in subprocedures (because they are local). |
Not strictly true - I believe that th table variables are on hard
drive as appropriate - try sticking a gig of data in one..
Check your query plans as well - the Table Variable dont get
statistics. This may have a relevance for you. I found that
paralellism _seems_ to be destroyed with table variables. Eg
inserting into a #table is fine with loads of parallelism, yet insert
into a seemingly identical @table and the paralelism disapears - in my
case turning the insert into 20 minutes instead of 30 seconds.