Sql-server – View in SQL Server 2008

sql serversql-server-2008

I am in need of getting data from multiple select queries. So I thought of creating two views and to inner join them to get my data.

My questions is: which option is better

  1. creating a view,
  2. creating temporary table

Best Answer

Using two VIEWs in your SELECT statement will always be better because it can combine both of the views query plans into a single optimised query. Very neat solution which is also fast.

BTW. Using an in-memory temp table > 100 rows generally poor performance because the query plan optimiser assumes there is only 1 row in the temp table.