jeannepine
New Member
I have the following SQL \[code\]with X(x) as (select 'a' union select 'b' ) , Y(y) as (select 1 union select 2 union select 3)select x, y from X cross join Yfor xml path('')\[/code\]and it returns\[code\]<x>a</x><y>1</y><x>a</x><y>2</y><x>a</x><y>3</y><x>b</x><y>1</y><x>b</x><y>2</y><x>b</x><y>3</y>\[/code\]Is it possible to make it returns\[code\]<a><y>1</y><y>2</y><y>3</y></a><b><y>1</y><y>2</y><y>3</y></b>\[/code\]or\[code\]<x v="a"><y>1</y><y>2</y><y>3</y></x><x v="b"><y>1</y><y>2</y><y>3</y></x>\[/code\]Or maybe I should do the permutation using xquery FLWOR?