Amongst other uses, recompiling your stored procedures can be useful especially when you want to ensure that you haven't deleted/renamed any columns/tables.
The following queries shown below recompile all stored procedures the next time they are run.
Recompiling all the Stored Procedures in a Database
-- Recompile all Stored Procedures and Triggers on a Database
EXEC sp_MSforeachtable @command1="EXEC sp_recompile '?'";
Note: See my post over here for other uses of sp_MSforeachtable 8 Common Uses of the undocumented Stored Procedure sp_MSforeachtable
Recompile all the Stored Procedures in a Table
-- Recompile all Stored Procedures that act on the Customer table
EXEC sp_recompile N'Sales.Customer';
Recompile a specific Stored Procedure
-- Recompile a specific Stored Procedure uspGetEmployeeManagers
EXEC sp_recompile 'uspGetEmployeeManagers';
Did you like this post?
|subscribe via rss||subscribe via e-mail|
|print this post||follow me on twitter|