开发者

Deleting cache/turning off caching from SQL Server Management Studio

I'm very new to Microsoft's SQL Server Management Studio 2008 R2. I am having an issue where I write a query, but the data that comes back is old. This is very frustrating, is there a way to turn off the caching of data, and how can I delete the old cached data so I am guaranteed to always see the most current data on the database.

Thank you for all your help in advance, I have not been able to have much success in finding this an开发者_JAVA技巧swer thus far.


Sql Server does cache data by keeping data pages in RAM for as long as it can, depending on how much memory the server has. However, as 2boolORNOT2bool pointed out, Sql Server should never serve up stale data. I am pretty sure if the underlying data in the table changes, Sql Server will invalidate the cache.

If you still want to try clearing the cache, try these DBCC statements at the beginning of your query:

      DBCC DROPCLEANBUFFERS 
      DBCC FREEPROCCACHE


You cannot delete reports from the cache directly unless you use the SOAP API. Disable Sql 2008 caching?

"Turning off (or attempting to turn off) SQL Server caching is thinking about the problem completely the wrong way. If the data is cached in your data layer tier, you should refresh it there. SQL Server will never serve up stale data." @Mitch Wheat

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜