Today’s an impromptu post, and the intention is to draw attention to a “hidden” feature of the SQL Server Management Studio (SSMS).
Recently, we were working on designing changes that were required in an XML that was required to be exchanged between the application and the database. The team had gathered in a meeting room for a technical design session – a couple of application developers, a database developer and a database administrator.
We had the SQL Server Management Studio running to look at the table design and create/query test data. To edit the existing XML, the application developers launched an instance of the Visual Studio IDE. The database developer and administrator immediately mentioned that there was no need to launch Visual Studio. The question that came from the application team was – “Why?” The simple answer is
SSMS comes with it’s own XML editor!
Here’s the problem though – it’s not obvious. The XML editor in the SSMS is an extension to the query editor window, which is probably why it’s not obvious. The tools and options related to XML editing are only available if an XML document is actually opened within the SSMS. I prepared a sample XML document for this post, and simply opened it using the SSMS. This is how the SSMS interface changes.
Notice that in the Text Editor toolbar, we now have the additional operations enabled (from Left to Right):
- Create XML schema based on given XML document
- Reformat Selection
- Format the whole Document
- Show XSLT output
- Debug XSLT
- Cancel XSLT output
The reason one can edit XML documents within the SSMS is because the SSMS is ultimately a Visual Studio shell, inheriting call features common at the shell.
Do you use the XML editor within SSMS? Do leave a note as you go.
Until we meet next time,
It is also an XSD editor that allows you to create XML Schema Definitions, with intellisense and real-time validations. It also has the capability to auto-generate the schema of an XML document/fragment.
Unfortunately, there does not seem to be a simple way to open the XML editor window. I submitted a [connect item] in 2008 which is unfortunately closed as “wont fix”. I need this window quite often and the short cut I am doing is to run `SELECT 1 AS A FOR XML PATH(”)` which produces a dummy XML result and then I click on the XML result to open the XML editor.
I really look forward to see a menu, tool-bar button or keyboard short cut some day to open the XML editor.
Thank-you for sharing additional information about the editor, Jacob. It’s indeed sad that there is no easy way to launch the XML editor window. Although the connect item is closed, I added my vote of support to it – just in case Microsoft looks at “changed after closed” metrics.