My situation is (simplified):
DECLARE @period XML = (
SELECT
'2012' 'period'
FOR XML PATH(''), ROOT ('survey'))
DECLARE @persons XML = (
SELECT
Person.Name 'users/person'
FROM Person
FOR XML PATH(''), ROOT ('company'))
SET @persons.modify('insert sql:variable("@period") as first into (/company)[1]')
SELECT @persons
What gives me this XML:
<company>
<survey>
<period>2012</period>
</survey>
<users>
<person>Dubach</person>
</users>
<users>
<person>Pletscher</person>
</users>
...
Now I need to add the XML schema to the root directory of the node as follows:
<company xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mydomain.com/xmlns/bla/blabla/myschema.xsd" xmlns="http://www.mydomain.com/xmlns/bla/blabla">
<survey>
<period>2012</period>
</survey>
<users>
<person>Dubach</person>
</users>
<users>
<person>Pletscher</person>
</users>
...
Microsoft states that I must use WITH XMLNAMESPACES before the SELECT statement , but this does not work in my case.
How to add these xmlnames spaces?
source
share