1. SYNTAX | |||
Below is the sample example of Creating a Temporary Table, Inserting records into it, retrieving the rows from it and then finally dropping the created Temporary Table.
|
Below is the sample example of Declaring a Table Variable, Inserting records into it and retrieving the rows from it.
| ||
2. MODIFYING STRUCTURE | |||
we can use DDL statements i.e. Alter,Create,Drop
| Table Variables doesn’t support DDL statements like ALTER, CREATE, DROP etc, implies we can’t modify the structure of Table variable nor we can drop it explicitly. | ||
3. STORAGE LOCATION | |||
One of the most common MYTH about Temporary Table & Table Variable is that: Temporary Tables are created in TempDB and Table Variables are created In-Memory. Fact is that both are created in TempDB. | |||
4. TRANSACTIONS | |||
Temporary Tables support use of transactions defined by the user.
|
Table variables doesn’t support explicit transactions defined by the user.
| ||
5. USER DEFINED FUNCTION | |||
Temporary Tables are not allowed in User Defined Functions. | Table Variables can be used in User Defined Functions. |
Temp Table Vs Table Variable
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment