585 pts.
 SQL Server 2008 Insert Into vs Insert Statement Recompile
I have a stored procedure that executes a t-sql statement using sp_executesql. This t-sql code recompiles everytime it runs using "INSERT INTO" but when I use "INSERT" only it will not recompile. What is going on here?

sample:

create table #test (id int)

Recompile:

insert into #test select id from mytable

Not Recompile:

insert #test select id from mytable



Software/Hardware used:
SQL Server 2008
ASKED: March 23, 2011  7:34 PM
UPDATED: March 24, 2011  11:42 PM

Answer Wiki:
Last Wiki Answer Submitted:  Be the first to answer this question.
All Answer Wiki Contributors:  Be the first to answer this question.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Are you doing this test with both insert statements within the same batch of code (a stored procedure for example) or two different batches of code?

 64,520 pts.