• Article Topics

  • Become a member of the SQLDBASupport community and receive notifications of new posts by email

    Join 82 other followers

  • Are you writer? Become an Author! Mail to

    amitvaid81 @ gmail dot com

  • Founder

    This is journey of a SQL DBA. I now work as a Sr. Database Architect and Solution Consultant, generally in performance tuning, clustering or high availability. The opinions expressed herein are my own personal opinions through real time experience.

    Amit Vaid

  • Advertisements


SP_recompile needs a single parameter which is the table name after it.

ie: sp_recompile table_name

How it works is that it marks EVERY stored procedure for recompile that uses
this table and when the stored procedure is executed, it will recompile it
prior to the execution. It will only recompile the procedure once. It
essentially flags the stored procedures that are dependencies of this table.

You will need to issue one sp_recompile statement for each table you want
the dependant stored procedures to be recompiled for…

Here is this query to recompile all tables and stored procedures within a given database

SELECT 'Exec sp_recompile ' + name
FROM   sysobjects
ORDER  BY name 

Take the result and make it into a script



EXEC SP_RECOMPILE table_name2 


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: