SQL - Blank default namespaces

karwan4pc

New Member
I have a relation which has an XML column storing data in the following structure\[code\]<Report id="b5d9b8da-7af4-4257-b825-b28af91dd833"> <CreatedDate>04-12-2012</CreatedDate> <LastUpdated>04-12-2012</LastUpdated> <Reference>abc123</Reference></Report>\[/code\]I'm writing a stored procedure to retrieve all reports and join them and wrap them in a root node called reports. I have the following so far;\[code\]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 )\[/code\]Whilst this returns all the reports in the right format, there exists a blank default namespace on the report element like the following;\[code\]<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>\[/code\]Could someone explain a suitable way of excluding the namespace on the report element?Any help is greatly appreciated guys :)
 
Back
Top