Let us learn about Script to Clear Procedure Cache at Database Level.
In earlier version when we have to clear cache for any database we had access to DBCC command which we could run to clear the cache for a particular plan or for the server.
Here is the script which you can run on SQL Server 2016 and earlier versions:
1 | DBCC FREEPROCCACHE |
In SQL Server 2017 we now have a new script which we can run at the database level to clear the cache for that particular database. This is indeed a blessing for many when you just want to clear the cache for the database and not for the entire server, you can run the following script.
1 | ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE; |