4everAStudent
4everAStudent

Reputation: 43

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 answer thus far.

Upvotes: 2

Views: 8030

Answers (2)

bbeny
bbeny

Reputation: 642

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

Upvotes: 2

2boolORNOT2bool
2boolORNOT2bool

Reputation: 567

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

Upvotes: 1

Related Questions