How to let SQL Server know not to use Cache in Queries?

Viewed 35380

Just a general question:

Is there a query/command I can pass to SQL Server not to use cache when executing a particularly query?

I am looking for a query/command that I can set rather than a configuration setting. Is there no need to do this?

4 Answers

Another more localized way to not use the MS-SQL Server Cache is to use the OPTION(RECOMPILE) keyword at the end of your statement.

E.g.

SELECT Columnname
FROM TableName
OPTION(RECOMPILE)

For more information about this and other similar query-cache clues to help identify problems with a query, Pinal Dave (no affiliation) has some helpful info about this.

Related