Flush Clear All Cache in SQL Server

There are times when you need to clear all cache. The below simple query lets you clear all cache on SQL Server for all databases.

sp_MSforeachdb 'USE [?];

PRINT DB_NAME()

DBCC DROPCLEANBUFFERS

DBCC FREEPROCCACHE

DBCC FREESESSIONCACHE

DBCC FREESYSTEMCACHE ( ''ALL'')'

A sample output would be as below