I have a relation that has an XML column storing data in the following structure
<Report id="b5d9b8da-7af4-4257-b825-b28af91dd833">
<CreatedDate>04-12-2012</CreatedDate>
<LastUpdated>04-12-2012</LastUpdated>
<Reference>abc123</Reference>
</Report>
I am writing a stored procedure to retrieve all reports and join them and transfer them to the root node called reports. So far I have the following:
WITH XMLNAMESPACES(DEFAULT 'http://www.defaultnamespace.com/1.0')
SELECT
@Xml =
(
SELECT
(
SELECT xml.query('.')
FROM
[database].[Reports]
WHERE
ClientId = @clientId
FOR XML PATH(''),
TYPE
)
FOR XML PATH('Reports'),
TYPE
)
As long as this returns all reports in the correct format, there is an empty default namespace in the report element, for example the following:
<Reports xmlns="http://www.defaultnamespace.com/1.0">
<Report xmlns="" id="b5d9b8da-7af4-4257-b825-b28af91dd833">
<CreatedDate>04-12-2012</CreatedDate>
<LastUpdated>04-12-2012</LastUpdated>
<Reference>abc123</Reference>
</Report>
</Reports>
Can someone explain a suitable way to exclude a namespace in a report element?
Any help really appreciated by the guys :)
source
share