Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is the difference between temp table and table variable?

Answer Posted / jerry joseph

SYNTAX
Temporary Tables: CREATE table #T (…)
Table Variables: DECLARE @T table (…)

Table Variables are out of scope of the transaction mechanism.
If you make changes to a Temp Table inside a Transaction and
Rollback the Transaction those changes will be lost.
Changes made to Table Variable inside a Transaction will
remain even if you Rollback the Transaction

Any procedure with a temporary table cannot be pre-compiled
An execution plan of procedures with table variables can be
statically compiled in advance

Table Variables exist only in the same scope as variables.
They are not visible in inner stored procedures and in
exec(string) statements

Table variables are in-memory structures that may work from
2-100 times faster than temp tables.

Access to table variables gets slower as the volume of data
they contain grows.

At some point, table variables will overflow the available
memory and that kills the performance.

Use table variables only when their data content is
guaranteed not to grow unpredictably; the breaking size is
around several thousand records.

For larger data volumes, use temp tables with clustered
indexes.

Is This Answer Correct ?    13 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain in brief about Microsoft SQL server?

1094


How many types of schemas are there?

1041


Tell me about pre-defined functions of sql?

1112


what are the different ways of moving data/databases between servers and databases in sql server? : Sql server database administration

979


What is the preferred way to create a clustered and non-clustered index? Which index should you create first the clustered or non-clustered?

914


What are magic tables in sql server?

1133


What are cascading parameters in ssrs reports?

229


What are the types of dml?

978


How does using a separate hard drive for several database objects improves performance right away?

932


What is row_number()?

983


Explain alternate key, candidate key and composite key in sql server?

914


How to modify an existing stored procedure in ms sql server?

1079


Does sql server 2016 have ssms?

960


How to list all schemas in a database?

1056


What is 2nf normalization form?

1136