SP_recompile


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
WHERE  TYPE = 'U'
ORDER  BY name 

Take the result and make it into a script

eg.


EXEC SP_RECOMPILE table_name

EXEC SP_RECOMPILE table_name2 

Advertisements

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: