The following script gets the database ID for a specific database a flushes the stored procedures from the server cache, only for this specific database.
This is only intended for testing. Don’t do this on a production system because it could crash and produce a bottleneck, forcing you to restart your server.
So here you have:
DECLARE @intDBID INTEGER; SET @intDBID = (SELECT dbid FROM master.dbo.sysdatabases WHERE name = 'dbname'); PRINT @intDBID; DBCC FLUSHPROCINDB (@intDBID);
I’ve tried this on a SQL 2008 R2 box.