Monday, May 12, 2008

difference between @Table datatype and temporary able?

Table variables are Transaction neutral. They are variables and thus aren't bound to a transaction.Temp tables behave same as normal tables and are bound by transactions.
The Next difference is that transaction logs are not recorded for the table variables. Hence, they are out of scope of the transaction mechanism.
The Third major difference is that any procedure with a temporary table cannot be pre-compiled, while an execution plan of procedures with table variables can be statically compiled in advance. Pre-compiling a script gives a major advantage to its speed of execution.
Finally, table variables exist only in the same scope as variables. Contrary to the temporary tables, they are not visible in inner stored procedures and in exec(string) statements. Also, they cannot be used in an insert/exec statement.

No comments: