Friday, 7 June 2013

How to clear data from cache memory ?

0)     
data cache
as of 15.0.3 - dbcc cachedataremove (dbid | dbname , objid | objname , partitionid | partitionname , indid | indexname)
you need sa_role for that as well
pre-15.0.2 ESD6
- try sp_unbindcache_all 'default data cache'
for example to clear "default data cache".  For named data caches, you should do this, followed by a sp_bindcache again for each object bound to a named cache

statement cache

set statement_cache off    -- session level
<your sql statements here>
or
sp_configure 'statement cache size',0  -- server level

procedure cache

In 12.5.4 ESD5 and 15.0.2 :   dbcc proc_cache (free_unused)pre 12.5.4 ESD5     :    dbcc proc_cacherm(type, dbname, objname)

where: type is V,P,T,R,D,C,F, or S (must be uppercase) corresponds to View, Proc, Trigger, Rule, Default, Cursor, SQLJ Function, SQL function.