select '20190302' as date_declaration, 'abc' as Type_Fischier, 1 AS numero_de_remise
into #ENTETE;
select '' as cib_emetteur into #DECLARATION;
select 'c' as type_mouvement, 11111 as type_tcn, 'fr12345' as code_isin
into #CARATERISTIQUE_TITRE;
go
select
(
select *
from #ENTETE
for xml path('ENTETE'), type
),
(
select *
from #DECLARATION
for xml path('DECLARATION'), type
),
(
select *
from #CARATERISTIQUE_TITRE
for xml path('CARATERISTIQUE_TITRE'), type
)
for xml path(''), type;
declare @result xml = (
select
(
select *
from #ENTETE
for xml path('ENTETE'), type
),
(
select *
from #DECLARATION
for xml path('DECLARATION'), type
),
(
select *
from #CARATERISTIQUE_TITRE
for xml path('CARATERISTIQUE_TITRE'), type
)
for xml path(''), type
);
select @result;
go