3

我在 SQL Server 2005 中有一个视图,其中包含一列 xml 数据。该列来自for xml path()查询,即

SELECT     e.id, eventTypeCode, e.startDate, e.endDate,
(select v.name 
 from venue v inner 
 join eventVenue ev on ev.venueCode=v.code 
 where ev.eventId=e.id for xml path('venue')) as venues    
FROM dbo.event e 
inner join eventType t on e.eventTypeCode=t.code 

我现在想在以 xml 形式返回数据的存储过程中引用此视图,即

create procedure getWebsiteMainCalendarEvents
@startDate datetime,
@endDate datetime
as
select * from vwWebsiteMainCalendar 
 where startDate between @startDate and @endDate 
order by startDate for xml path() element

当我运行该过程时,我希望视图中的场所显示为子节点,但<>编码为 html 实体。有没有办法让程序将 xml 数据视为输出中的 xml 节点?

4

1 回答 1

0

我已经整理好了。视图应该已将“类型”附加到 for xml path(),即

-- VENUES
(select v.name from venue v inner join eventVenue ev on ev.venueCode=v.code where ev.eventId=e.id for xml path('venue'))

应该

-- VENUES

(从场地 v 内部选择 v.name 加入 eventVenue ev on ev.venueCode=v.code where ev.eventId=e.id for xml path('venue'), type

于 2012-06-29T09:39:23.427 回答