Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select '{"mountains":['
- + STUFF((
- select
- ',{"name":"' + m.MountainRange + '"'
- +',"peaks":' + '[' +
- -----------GET PEAKS FOR MOUNTAIN
- ISNULL((select STUFF(
- (select
- ',{"name":"' + + p.PeakName + '"'
- + ',"elevation":' + cast(p.Elevation as nvarchar(max))
- +'}'
- from Peaks p
- where p.MountainId = m.Id
- ---order by p.PeakName
- for xml path(''), type
- ).value('.', 'nvarchar(max)'), 1, 1, '') ),'')
- -----------GET PEAKS FOR MOUNTAIN END
- + ']' + '}'
- FROM Mountains m
- ---order by m.MountainRange
- for xml path(''), type
- ).value('.', 'nvarchar(max)'), 1, 1, '') + ']}'
- GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement