From the course: Developing Microsoft SQL Server 2016 Databases

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Recompile a stored procedure

Recompile a stored procedure

- [Instructor] One of the benefits of the store procedure is that SQL Server can predict how they'll be used and how best to execute them. There are instances though when the procedure will need to be evaluated again through a process called recompiling. When you execute a stored procedure for the first time SQL Server will analyze the procedure, including any parameters that were passed into it, in order to determine the most efficient way to obtain the results. This generates something called an execution plan, and the plan is cached on the system in order to speed up the processing of the stored procedure the next time it's run. When using parameterized store procedures though this can cause an issue since the most efficient way to execute or process a stored procedure with one set of parameters is not necessarily the best way to process it with another. Due to a process called parameter sniffing, the parameters that…

Contents