select (select p.ProblemType as 'td' for xml path(''), type), (select p.onsetas 'td' for xml path(''), type), (select p.DiagnosisStatus as 'td' for xml path(''), type)from tblProblemList pwhere p.PatientUnitNumber = @PatientUnitNumberfor xml path('tr')要添加标题,也可以使用
union all。
select (select 'Problem' as th for xml path(''), type), (select 'Onset' as th for xml path(''), type), (select 'Status' as th for xml path(''), type)union all select (select p.ProblemType as 'td' for xml path(''), type), (select p.onsetas 'td' for xml path(''), type), (select p.DiagnosisStatus as 'td' for xml path(''), type)from tblProblemList pwhere p.PatientUnitNumber = @PatientUnitNumberfor xml path('tr')


