sql-server-2008-r2table-variabletemp-tables

Is using Table variables faster than temp tables


Am I safe to assume that where I have stored procedures using the tempdb to write a temporary table, I'd be better off switching these to table variables to get better performance?


Solution

  • Temp tables are better in performance. If you use a Table Variable and the Data in the Variable gets too big, the SQL Server converts the Variable automatically into a temp table.

    It depends, like almost every Database related question, on what you try to do. So it is hard to answer without more information.

    So my answer is, try it and have a look at the execution plan. Use the fastest way with the lowest costs.