我知道如何进行联合并从不同的表中吐出一个 XML 文件,但是,我需要创建一个临时表来容纳我需要成为 XML 文件一部分的 3 条记录。结构与其他表完全相同。
我该怎么做呢?
select * from
(
select ID_Number as [ID], CLAST as [name/last], CFIRST as [name/first], '' as extension]
from dbo.users as a
union all
select PID as [ID], NID as [name/last], NAME as [name/first], PREF_TITLE as [extension]
from dbo.Person
) as a
FOR XML PATH('employee'), ROOT('employees')
所以我需要 3 行数据,它们将填写 ID、姓名/姓氏、姓名/名字和扩展名。
最好的建议是什么?