Requires VIEW_SERVER_STATE permission. In addition, individual permissions are required for each plan guide that is created by using sp_create_plan_guide_from_handle. To create a plan guide of type OBJECT requires ALTER permission on the referenced object. To create a plan guide of type SQL or TEMPLATE requires ALTER permission on the current database. To determine the plan guide type that will be created, run the following query:
SELECT cp.plan_handle, sql_handle, st.text, objtype
FROM sys.dm_exec_cached_plans AS cp
JOIN sys.dm_exec_query_stats AS qs ON cp.plan_handle = qs.plan_handle
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS st;
In the row that contains the statement for which you are creating the plan guide, examine the objtype column in the result set. A value of Proc indicates the plan guide is of type OBJECT. Other values such as AdHoc or Prepared indicate the plan guide is of type SQL.