Query inside WITH XMLNAMESPACE clause

IndyG

New Member
is it possible to get some data of the namespaces in the result xml of FOR XML Clause from database e.g. \[code\]WITH XMLNAMESPACES ('uri1' as ns1, 'uri2' as ns2, DEFAULT 'uri2')SELECT ProductID, Name, ColorFROM Production.Product WHERE ProductID=316 or ProductID=317FOR XML RAW ('ns1:Product'), ROOT('ns2:root'), ELEMENTS\[/code\]RESULTS : \[code\] <ns2:root xmlns="uri2" xmlns:ns2="uri2" xmlns:ns1="uri1"> <ns1:Product><ProductID>316</ProductID><Name>Blade</Name> </ns1:Product> <ns1:Product><ProductID>317</ProductID><Name>LL Crankarm</Name><Color>Black</Color> </ns1:Product> </ns2:root>\[/code\]WHAT IF I'D LIKE TO GET THE VALUE OF FROM INSIDE DATABASE ? something like this : \[code\]WITH XMLNAMESPACES ('uri1' as ns1, **(SELECT namespace from tableName)** as ns2, DEFAULT 'uri2')\[/code\]
 
Back
Top