#0188-SQL Server-How to edit XML documents with the SSMS? Using XML Editor feature of SSMS


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.


image


Notice that in the Text Editor toolbar, we now have the additional operations enabled (from Left to Right):



  1. Create XML schema based on given XML document
  2. Reformat Selection
  3. Format the whole Document
  4. Show XSLT output
  5. Debug XSLT
  6. 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,


Be courteous. Drive responsibly.

Advertisements

2 thoughts on “#0188-SQL Server-How to edit XML documents with the SSMS? Using XML Editor feature of SSMS

  1. Jacob Sebastian

    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][1] 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.

    [1]: https://connect.microsoft.com/SQLServer/feedback/details/355997/no-menu-or-keyboard-shortcut-available-to-launch-the-xml-editor-ssms

    Like

    Reply
  2. Nakul Vachhrajani

    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.

    Like

    Reply

Let me know what you think about this post by leaving your feedback here!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s