Clean up stored procedures' cache with SQL Server

Posted by Andrea on 2009-03-06 12:30
If you're deploying a stored procedure, you should clean up the db's cache in order to apply changes immediately.
Take a look to the following code:
-- Cleans up db's cache
DECLARE @dbID INTEGER
SET @dbID = (SELECT dbid FROM master.dbo.sysdatabases WHERE name = 'DBNameHere')
DBCC FLUSHPROCINDB (@dbID)
The DBCC FLUSHPROCINDB command
Allows you to specify a particular database id, and then clears all plans from that particular database.