Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Convert XML to String with formatting

By Andrei Solntsev,

Recently I needed to display an XML column on SSRS report. XML has just few tags, but tags were different from row to row. I thought no problem, just include it to data set and add that field into table. But I was terribly wrong. It turned out that SQL server converts xml into a single line sting which is not readable as all, but I wanted present it nicely: something similar to how xml displayed in Management Studio, but without colours.

Internet search did not give me good solution so I decided to write own function which renders xml into text with each tag on separate line and proper indents. Below is the function I wrote. Hope it saves time to someone in similar situation.



Total article views: 1505 | Views in the last 30 days: 6

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones