SQL Server 2008 Insert Into vs Insert Statement Recompile

585 pts.
Tags:
SQL
SQL Server
SQL Server 2008
T-SQL
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

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Denny Cherry
    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?
    66,140 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following