Formatted XML in Microsoft Server Management Studio

There is a less known possibility in the SQL Management studio to format XML datatype. The format is fine for reading and you don’t need to format the XML anywhere else.

The whole trick is to use cast to tell SMSS to format the column in the nice form.

This is working with any valid XML, I have tested with varchar(max) and ntext column types.

Just use command similar to this:

SELECT cast(Settings as xml), *
  FROM [BlogEngine].[martinkunccom].[be_DataStoreSettings]

The result you will see is like on following image:

Now, you can simply click on the blue text and it will show inside the SQL Management Studio viewer in a nice form:

Nice, isn’t it ?

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s