0
我想从表中读取一个varchar列,但此列实际上是Xml,所以我将该值转换为XML并试图从那里获取值。获取null尝试读取XML列值SQL
问题是我总是变空。这是我的代码:
declare @Greeting xml = (select CAST(sg.Greeting as xml) from AnsService.Ans.SiteGroup sg with (nolock) where sg.SiteGroupNum = 2032)
select
sg.AnswerAs,
(select xmlData.Col.value('.', 'varchar(max)') from @Greeting.nodes('//Section/Paragraph/Run') xmlData(col)) as Greeting
from AnsService.Ans.SiteGroup sg with (nolock)
where sg.SiteGroupNum = 2032
转换后的XML值是:
<Section xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xml:space="preserve>
<Paragraph>
<Run>Thank you for calling Intelli-tec Security Services. This is [OpFirst] speaking, how may I help you?</Run>
</Paragraph>
</Section>
任何人都可以帮助我在这里找出我的问题,谢谢
非常感谢@Shnugo你是最好的,你的回答是绝对正确的。我非常感谢你对此的帮助。所有的建议都是可悲的,因为数据库不是我的,所以我必须以实施的方式使用它。非常感谢。 –