Hello,

I'm in trouble with XMLNAMESPACES declaration in SqlServer2005 !
I used this declaration to put the namesspaces in the root element but with my query i have this declaration in all my nodes !

Code:
WITH XMLNAMESPACES ('urn:PCCAD:A1:schema' as PCCAD_A1,
					'urn:PCCAD:A2:schema' as PCCAD_A2,
					'urn:PCCAD:A3:schema' as PCCAD_A3,
					'urn:PCCAD:A4:schema' as PCCAD_A4,
					'urn:PCCAD:A5:schema' as PCCAD_A5,
					'urn:PCCAD:A6:schema' as PCCAD_A6,
					'http://www.w3.org/2001/XMLSchema-instance' as xsi)

SELECT 
	(
		SELECT '1' AS '@ID'
		FOR XML PATH ('ELEMENT1'), TYPE
	),
	(
		SELECT '2' AS '@ID'
		FOR XML PATH ('ELEMENT2'), TYPE
	)

FOR XML PATH ('ROOT')
My result :
Code:
<ROOT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:PCCAD_A6="urn:PCCAD:A6:schema" xmlns:PCCAD_A5="urn:PCCAD:A5:schema" xmlns:PCCAD_A4="urn:PCCAD:A4:schema" xmlns:PCCAD_A3="urn:PCCAD:A3:schema" xmlns:PCCAD_A2="urn:PCCAD:A2:schema" xmlns:PCCAD_A1="urn:PCCAD:A1:schema">
  <ELEMENT1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:PCCAD_A6="urn:PCCAD:A6:schema" xmlns:PCCAD_A5="urn:PCCAD:A5:schema" xmlns:PCCAD_A4="urn:PCCAD:A4:schema" xmlns:PCCAD_A3="urn:PCCAD:A3:schema" xmlns:PCCAD_A2="urn:PCCAD:A2:schema" xmlns:PCCAD_A1="urn:PCCAD:A1:schema" ID="1" />
  <ELEMENT2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:PCCAD_A6="urn:PCCAD:A6:schema" xmlns:PCCAD_A5="urn:PCCAD:A5:schema" xmlns:PCCAD_A4="urn:PCCAD:A4:schema" xmlns:PCCAD_A3="urn:PCCAD:A3:schema" xmlns:PCCAD_A2="urn:PCCAD:A2:schema" xmlns:PCCAD_A1="urn:PCCAD:A1:schema" ID="2" />
</ROOT>
And i only want the namespaces declartion in the root, like this :
Code:
<ROOT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:PCCAD_A6="urn:PCCAD:A6:schema" xmlns:PCCAD_A5="urn:PCCAD:A5:schema" xmlns:PCCAD_A4="urn:PCCAD:A4:schema" xmlns:PCCAD_A3="urn:PCCAD:A3:schema" xmlns:PCCAD_A2="urn:PCCAD:A2:schema" xmlns:PCCAD_A1="urn:PCCAD:A1:schema">
  <ELEMENT1 ID="1" />
  <ELEMENT2 ID="2" />
</ROOT>
It 's better because it's lighter and easier to read !

Any help ?

Thanks !