Clear mssql cache

If you for example need to test a query against two SQL servers hardware, its a good idea to clear the cache first.
This query can do this:

DBCC DROPCLEANBUFFERS; 

-- Removes all elements from the plan cache.

DBCC FREEPROCCACHE;

-- Displays the number of milliseconds required to parse, compile, and execute each statement.

SET STATISTICS TIME ON; 

-- Display information regarding the amount of disk activity generated by Transact-SQL statements.

SET STATISTICS IO ON; 

Leave a Reply

Your email address will not be published. Required fields are marked *