Wednesday, July 7, 2010

Temperory Tables and Table Variables in SQL 2008

This is one of queries programmers would have come across. And you may face this question when you attend a technical viva session.

There are primary 3 differences i can say

1) There are no transaction logs recorded for table variables. That being said, it is out of transaction mechanism.

2) Any piece of code, say stored procedure will not be compiled if temperory table exists where as one with table variable can be pre-compiled. This boost the performance when use table variables.

3) The scope of the table variable is limited to the local scope. In essence, table variables will not be available for inner stored procedures and statements.

Hope this helps.!

No comments:

Post a Comment