CREATE PROCEDURE [dbo].[FindOneTimeUseQueries] AS BEGIN SET NOCOUNT ON; select top 100 refcounts, usecounts, size_in_bytes /1024 as sizeInKb, text from sys.dm_Exec_cached_plans cross apply sys.dm_exec_sql_text(plan_handle) where cacheobjtype = 'Compiled Plan' and objtype = 'Adhoc' and usecounts = 1 and text not like 'FETCH API_CURSOR%' order by size_in_bytes desc END exec [dbo].[FindOneTimeUseQueries] ;