Hello I have 2 tables
Programme: ProgrammeID, Start Date, End Date
Title: ID, ProgrammeID, Language, Title
I need a query that will return
<programme startdate='blah' enddate='blah'>
<title lang='en'>Some Title</title>
<title lang='de'>Some other title</title>
</programme>
My problem is that usually when I have a structure like this I would return
<programme startdate='blah' enddate='blah'>
<titles>
<title lang='en'>Some Title</title>
<title lang='de'>Some other title</title>
</titles>
</programme>
but I need the first XML structure
What I have so far that is totally wrong is
SELECT e.[startdate] as '@start'
,e.[enddate] as '@end'
,e.MediaItemID as '@channel'
,(
SELECT
lang as '@lang'
,title as 'title'
FROM dbo.[MediaItemEPGtitle] et
WHERE e.[MediaItemEPGID] = et.[MediaItemEPGID]
FOR XML path ('title')
) as title
--,case e.[previouslyShown] when 0 then '' end as [previously-shown]
--,case e.[previouslyShown] when 2 then '' end as [new]
FROM [dbo].[MediaItemEPG] e
WHERE (e.enddate between @StartDate and @EndDate) or (e.startdate between @StartDate and @EndDate)
FOR XML PATH('programme'), TYPE, ROOT('tv') ;