2 蟲企慨蠍 #
襾殊 貎朱Μ襯 ろ 貂 襷る襦 .
USE AdventureWorks2008
GO
--貎朱Μろ
SELECT * FROM Person.Address
WHERE City = 'Bothell'
--
SELECT * FROM sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text(sql_handle)
CROSS APPLY sys.dm_exec_text_query_plan(qs.plan_handle, qs.statement_start_offset, qs.statement_end_offset) qp
WHERE text LIKE N'SELECT * FROM Person.Address
WHERE City = ''Bothell''%'
GO
れ朱 螳企襯 燕 覲伎.
DECLARE @plan_handle varbinary(64)
DECLARE @offset int
SELECT @plan_handle = plan_handle, @offset = qs.statement_start_offset
FROM sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text(sql_handle)
CROSS APPLY sys.dm_exec_text_query_plan(qs.plan_handle, qs.statement_start_offset, qs.statement_end_offset) qp
WHERE text LIKE N'SELECT * FROM Person.Address
WHERE City = ''Bothell''%'
EXEC sp_create_plan_guide_from_handle --CTP覯 sp_create_plan_guide_from_cache襦 .
@name = N'CustomerSales',
@plan_handle = @plan_handle,
@statement_start_offset = @offset
GO
燕/觜燕 り鍵
EXEC sp_control_plan_guide N'DISABLE', N'CustomerSales'
GO
SELECT * FROM sys.plan_guides
WHERE is_disabled = 1 --disable 蟆..
GO
EXEC sp_control_plan_guide N'ENABLE', N'CustomerSales'
GO