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 / yugal

1) Table variables don't participate in transactions,
logging or locking. This means they're faster as they don't
require the overhead, but conversely you don't get those
features.
2) 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.
This advantage can be dramatic for long procedures, where
recompilation can be too pricy
3) 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.
4) You can create a temp table using SELECT INTO, which can
be quicker to write (good for ad-hoc querying) and may
allow you to deal with changing datatypes over time, since
you don't need to define your temp table structure upfront.
5) You cannot truncate a table variable but temporary table
can be truncated.
6) You cannot drop a table variable when it is no longer
necessary—you just need to let it go out of scope but
temporary table can be dropped.
7) Table variables cannot be altered after they have been
declared but temporary table can be altered.

Is This Answer Correct ?    6 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What happens if the update subquery returns no rows in ms sql server?

1072


Explain foreign key in sql server?

973


How to drop an existing schema in ms sql server?

1019


How to use the inserted and deleted pseudo tables?

911


How sql server enhances scalability of the database system?

1108


How do I start sql server 2016?

853


Explain Geometry datatype in sql server 2008 with example

916


What is sqlservr.exe - process - sql server (sqlex?press)?

1052


What is the difference between cartesian product and cross join?

812


What is a join in sql? What are the types of joins?

1005


Working with TLogs

1781


Can we call stored procedure in view in sql server?

859


How to rebuild indexes with alter index ... Rebuild?

1030


What is xml datatype?

1028


What is SQL Azure Firewall?

134