如何清除sql server中1个存储过程的缓存 [英] How to clear cache of 1 stored procedure in sql server

查看:36
本文介绍了如何清除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....);

这篇关于如何清除sql server中1个存储过程的缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆