Sqlserver清理緩存和內存

--清除存儲過程緩存  
DBCC FREEPROCCACHE 
--清除會話緩存 
DBCC FREESESSIONCACHE 
--清除系統緩存 
DBCC FREESYSTEMCACHE('All') 
--清除全部緩存 
DBCC DROPCLEANBUFFERS
GO
 
--打開高級配置 
exec sp_configure'show advanced options', 1 
GO
--設置最大內存MB  2G
exec sp_configure 'max server memory', 2048 
EXEC ('RECONFIGURE' )
--設置執行時間
WAITFOR DELAY '00:00:10'
--設置最大內存MB  20G
EXEC  sp_configure 'max server memory', 20480 
EXEC ('RECONFIGURE' )
GO
--關閉高級配置 
exec sp_configure'show advanced options',0 
GO