Another cool new feature introduced in MSSQL 2005 - SET showplan_xml ON - will show T-SQL query estimated execution plan in XML format, so one can do whatever he wants with it - send by mail, parse, save, etc. If you save the result to the file having .sqlplan extension, the MSSQL Management Studio will open the file and render the execution plan graphics.
In addition there is a new query hint introduced in MSSQL 2005 called USE PLAN N'xml_plan' to force using the plan just saved with SET showplan_xml.
"You can change the plan before you use it by using USE PLAN, such as by changing join orders and operators, and adjusting scans and seeks. However, format of the plan must still match Showplanxml.xsd. You may not be able to force a plan that has been changed. An error occurs if you use a plan in a USE PLAN hint when the plan is not one of the plans that SQL Server would typically consider for the query during optimization."
"Query plans generated with the USE PLAN query hint are cached just like other query plans."
Monday, November 14, 2005 3:03 AM