I am extracting some data from SQL Server. One of the columns is a ntext column that has a blob of XML there. As I extract it, it looks really ugly. Is there any way to format the XML inside a SQL Server 2005 stored proc?
A:
Not easily, but if you INSERT it with formatting, then sqlserver will keep the formatting when you extract it. Doing text formatting in SQL Server is pretty difficult as the functions available are very limited.
hova
2009-02-26 19:13:22
+2
A:
There is no "make this pretty" function in SQL Server. You can do it in .NET, however, so one option is setting up a CLR function that makes the output of XML pretty. As this is NText, you will have to exception handle any string that is not XML, or you will have a blow up.
Gregory A Beamer
2009-02-26 19:15:05
found a good blog post on how to do this @ http://blogs.msdn.com/mrorke/archive/2005/06/28/433471.aspx
Jared
2009-02-26 20:11:11
Interesting blog entry. I am not sure I would use XSL to "prettify" only, but it is a very good resource. Thanks Jared.
Gregory A Beamer
2009-02-27 15:34:11