microsoft / azuredatastudio

Azure Data Studio is a data management and development tool with connectivity to popular cloud and on-premises databases. Azure Data Studio supports Windows, macOS, and Linux, with immediate capability to connect to Azure SQL and SQL Server. Browse the extension library for more database support options including MySQL, PostgreSQL, and MongoDB.
https://learn.microsoft.com/sql/azure-data-studio
MIT License
7.5k stars 882 forks source link

Preserve leading whitespace (indents) in Azure Data Studio XML output #25647

Open OneEyedSi opened 1 month ago

OneEyedSi commented 1 month ago

By default Azure Data Studio seems to remove leading whitespace from the inner text in XML columns in the results of a query. In contrast SQL Server Management Studio (SSMS) retains leading whitespace in the inner text when displaying XML. Could Azure Data Studio be updated to retain the leading whitespace, like SSMS does, or include an option to do so?

Example:

declare @xml xml = 
'<root>
    <text>
Unindented text.
    Single indented text.
        Double-indented text.
    </text>
</root>';

select @xml;

Result in Azure Data Studio, after clicking on the XML output column in the result pane to open the XML in a separate window:

<root>
    <text>
        Unindented text.
        Single indented text.
        Double-indented text.
    </text>
</root>

Desired result:

<root>
    <text>
Unindented text.
    Single indented text.
        Double-indented text.
    </text>
</root>

I've tried unchecking setting Query Editor > Results > Save as Xml: Formatted but that doesn't make any difference so I assume it's for saving the results to a file.