プログラマーとプログラミングに熱心な人々のための質問と回答
declare @T table(id int, name varchar(20)) insert into @T values(321, 'Book') insert into @T values(654, 'Pen') select ( select 'id' as '@name', T.id as '@value' for xml path('column'), type ), ( select 'name' as '@name', T.name as '@value' for xml path('column'), type ) from @T as T for xml path('row'), root('root')