Is it possible to force a query plan on a Stored procedue. I have attempted the following and i receive a Incorrect syntax near the keyword 'OPTION'. Any ideas?
EXEC testdatabases..testprocedure
OPTION (USE PLAN N' 
<ShowPlanXML xmlns= 
"http://schemas.microsoft.com/sqlserver/2004/07/showplan" Version="0.5" 
Build="9.00.1187.07"> 
 <BatchSequence> 
 <Batch> 
 <Statements> 
 ... 
 </Statements> 
 </Batch> 
 </BatchSequence> 
</ShowPlanXML> 
') 
GO
You could use OPTION and USE PLAN only with SELECT/INSERT/DELETE/STATEMENTS. So move your plan in body of stored procedures.
If you couldn't change your stored procedure use Plan Guide by sp_create_plan_guide http://msdn2.microsoft.com/en-us/library/ms179880.aspx
 
No comments:
Post a Comment