1

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.

4everAStudent
  • 33
  • 3
  • 6
  • 1
    There is no caching of data in SQL Server. Perhaps this could be a replication problem, if you are using replication. It could be that you are using two different queries with uncommitted snapshot transactions. It could be that you are referencing the wrong table. It could be that you are querying a view that was created as a snapshot. Can you give us more information? – Jeffrey L Whitledge Apr 19 '11 at 20:21

2 Answers2

1

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
bbeny
  • 632
  • 1
  • 7
  • 18
0

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

Community
  • 1
  • 1
2boolORNOT2bool
  • 557
  • 3
  • 9
  • 23