If you create a stores procedure in SQL Server and execute it then it always in compiled form after it only you have need to execute it. Sometimes cases are generated in that we need to recompile our stored procedure. There are two simple way to recompile the stored procedure like as-
Lets create a Stored Procedure
CREATE PROCEDURE usp_ReturnProcedure
AS
BEGIN
SELECT * FROM Salesman;
RETURN;
END
1- The following method is used to recompile the stored procedure as well as execute it. By using this method you can recompile your stores procedure while you execute it,
EXEC usp_ReturnProcedure WITH RECOMPILE;
If you want to only execute the stored procedure then use the following SQL statement
EXEC usp_ReturnProcedure
2- The second method is only you can recompile your stored procedure here stored procedure is not execute. The following SQL statement is used to recompile the stored procedure,
EXEC sp_recompile usp_ReturnProcedure;
So you understand differences between above two methods for recompiling of stored procedure. In the first method procedure is recompile as well as execute also and in the second method stored procedure only being recompiles.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Recompile the Stored Procedure:
If you create a stores procedure in SQL Server and execute it then it always in compiled form after it only you have need to execute it. Sometimes cases are generated in that we need to recompile our stored procedure. There are two simple way to recompile the stored procedure like as-
Lets create a Stored Procedure
1- The following method is used to recompile the stored procedure as well as execute it. By using this method you can recompile your stores procedure while you execute it,
If you want to only execute the stored procedure then use the following SQL statement
2- The second method is only you can recompile your stored procedure here stored procedure is not execute. The following SQL statement is used to recompile the stored procedure,
So you understand differences between above two methods for recompiling of stored procedure. In the first method procedure is recompile as well as execute also and in the second method stored procedure only being recompiles.