While I was doing some work for Andy Warren (more on this after Sept 1st), I came across an interesting little glitch when saving XML execution plans out as SQLPlan files. It’s easy enough to replicate. Just get an XML execution plan from your query:
SET STATISTITCS XML ON;
Click on the link to open the XML plan. Click on the “File” menu and then the “Save As” menu item. It opens the familiar file save window. Click on the “Save as type” drop down and switch to “All Files (*.*)” Save the file with an extension of “.sqlplan.” Good. Now you’ve got an execution plan file that can be opened and viewed as a GUI execution plan. Without closing the XML, try to open this new plan. You should see an error that reads “Visual Studio has encountered an unexpected error.” Close that window and close the XML window. Now try reopening the .sqlplan file. Ta-da! Works fine.
I know this weird and not likely to be encountered much or cause serious problems, but I found it and thought I’d share it.