Andrea Azzola

Tips and Techniques for Lifestyle Design

Clean Up Stored Procedures Cache with SQL Server

Posted on [Permalink]

When deploying a stored procedure, a clean up the db's cache might go a long way in order to apply changes immediately. Have a look to the following code:

-- Cleans up db's cache
SET @dbID = (SELECT dbid FROM master.dbo.sysdatabases WHERE name = 'DBNameHere')

The DBCC FLUSHPROCINDB command allows for specifing a particular database id, and then clears all the plans from it.

Categories: SQL Server