-2

Why there are temporary table and table variable concepts in SQL server, when both of them provide the same functionality.

As table variable and temporary table uses the temp DB and have almost identical features.

sam
  • 17
  • 2
  • http://dba.stackexchange.com/questions/16385/whats-the-difference-between-a-temp-table-and-table-variable-in-sql-server/16386#16386 – Kritner Aug 10 '15 at 11:49
  • http://stackoverflow.com/questions/27894/whats-the-difference-between-a-temp-table-and-table-variable-in-sql-server – A_Sk Aug 10 '15 at 11:50

2 Answers2

0

Though they look same, there are signficant differences.

Major differences

  1. You can create indexes on Temp table. But not on table variable.
  2. You can pass table variable as parameter, but that is not the case with temp table.
  3. you can have transactions working on temp table, but not on table variable.

there are other differences. Just google it.

Sateesh Pagolu
  • 9,282
  • 2
  • 30
  • 48
0

One major difference is that you can't use temporary tables in user defined functions, but you can use table variables. I would assume that's because of the difference in scope -- and I would assume this is the reason why table variables have been implemented.

James Z
  • 12,209
  • 10
  • 24
  • 44