This may be surprising to many, but I have seen quite a few times so far so decided to blog over here.
Here is the sequence of the action:
- The developer turns on Graphical Execution plan for any query with CTRL+M
- Now turns on the execution plan in the text format with SET SHOWPLAN_TEXT ON command
- After this, the developer does his/her task to analysis the execution plan
- Now turns on the execution plan in the XML format with SET SHOWPLAN_XML ON command
Now when a developer has to turn back Graphical Execution Plan, he/she gets confused. We know that we can turn on TEXT and XML with the help of SET commands, but how to turn on graphical execution plans from T-SQL. Well, the matter of facts is there is no way to turn the graphical execution plan from T-SQL.
The only way to get the Graphical Execution plan back in SQL Server Management Studio (SSMS) is to turn off TEXT and XML plan and it will automatically turn on the graphical execution plan.
For example, in above situation when we have turned off TEXT and XML plan, set them off as described in the following steps
- Turn off XML execution plan with SET SHOWPLAN_XML OFF command
- Turn off TEXT execution plan with SET SHOWPLAN_TEXT OFF command
It will automatically turn on the graphical execution plan. Remember, if you have turned off either of XML or TEXT, you will need to turn off that one only. However, if you have turned on both of them, you will have to turn off both of them to get back your graphical execution plan.
Reference: Pinal Dave (https://blog.sqlauthority.com)