Usage of Temporary table:
If we want to use the table for some other stored procedure or else to be used after my scope of the query. We will prefer temporary table.
Manually, before creating a temporay table we have to delete the existing one
Two types of tables can be created,
1. Local Temporary table
2. Global Temporary table
If we restart the server, temporary tables will get deleted.
Usage of table variable:
If we need table's existence to be restricted with in the scope of the query and no need to be used in future. then we can prefer table variable.
The table variables will automatically get deleted after the scope may be between a begin and end statements.A new table variable cannot be created if an another table variable exists in the scope.
No need to explicitly drop the table.
Table variables are comparatively too fast in accessing the data because it will reduce the round trip like accessing the temp database to retrieve the data.
No comments:
Post a Comment