To retain cosnsistency for baseline testing and assist in query tuning use the following 2 commands:
Use DBCC DROPCLEANBUFFERS to flush out already cached plans.This will force the SQL Statement to recompile intstead of re using the cache available
Use DBCC FREEPROCCACHE to clear buffers from the buffer pool.
Running these 2 commands in between code changes allows a consistent comparision
/****************CODE START********************* use master DBCC DROPCLEANBUFFERS GO DBCC FREEPROCCACHE ************************************************/
Republished from http://www.sqlserver-dba.com.