【发布时间】:2014-02-05 01:11:01
【问题描述】:
我在其他地方尝试了一段 sql 查询来从 XML 字符串中获取值并且它可以工作,但是当我尝试在 几乎类似的情况下在其他地方实现它时,我收到了这个错误:
XML 数据类型方法节点的参数 1 必须是字符串字面量
我的查询是这样的:
Select * into #ContentItemsOnStaging from ( SELECT A.id as
NodeID,A.text as NodeName,B.text as Parent , A.createDate as
DateCreated ,
-- Problem is from here
( SELECT pref.value('(/' + E.alias
+'/@updateDate)[1]', 'datetime') AS LastUpdatedDate FROM
(SELECT CAST(xml AS xml) AS XmlCol FROM [ContentXml] WHERE nodeId = A.id )
AS XmlStuff CROSS APPLY XmlCol.nodes('/' + E.alias) AS x(pref) )
-- To Here
FROM [Node] as A left join Node B on A.parentID = B.id left join [ContentXml] as C on
A.id = C.nodeId left join [Content] as D on A.id = D.nodeId left join [cmsContentType]
as E on D.contentType = E.nodeId) as test2
问题来自 E.Alias。 我需要的是发送一个可自定义的 Header 以供搜索。有什么解决方法吗?
有什么想法吗?
【问题讨论】:
标签: sql-server xml