Thursday, October 31, 2013

Local temporary table vs table variable - SQL Server 2008 R2/2012


Ok, therefore in a stored procedure that using a SELECT with more JOINs to get some millions of data I could use a temp table to insert the resulting set. Then I could have this temp table to compute a GROUP BY before to perform the final insert into a SQL table.


Or, in this scenario is it better to use a SQL table to produce the intermediate result instead of a temp table?


Thanks



Try both approaches and chose better one.


Inserting millions of records( for the sake of group by) into a temp table itself may cost high.


So, implement both the approaches and compare and select the better one.




Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.


No comments:

Post a Comment