如何清除sql server中1个存储过程的缓存
我使用的是 SQL Server 2008 R2.
I am using SQL Server 2008 R2.
我知道 DBCC FREEPROCCACHE
将清除 SQL Server 中所有存储过程的缓存.
I know that DBCC FREEPROCCACHE
will clear cache of all stored procedures in SQL Server.
但我需要的是清除仅 1 个存储过程的缓存.我该怎么做?
But what I need is to clear cache of only 1 stored procedure. How can I do that?
存储过程名称是 Rpt_RegionReport
.我不想使用 WITH RECOMPILE
选项执行存储过程.
The Stored Procedure name is Rpt_RegionReport
. I don't want to execute the stored procedure with WITH RECOMPILE
option.
DBCC FreeProcCache
有一个可选参数 - 要删除的执行计划的 ID.
DBCC FreeProcCache
has a single optional argument - the ID of the execution plan you want to delete.
您可以使用sys.dm_exec_cached_plans
找到要删除的计划,然后就可以将其用作
You can find the plan you want to delete using sys.dm_exec_cached_plans
, and then you can just use it as
DBCC FREEPROCCACHE (0x0123456....);