SQL Server XQuery语法错误
我正在为SQLServer使用Serilog接收器,并使用link遵循DB模式和XQuery语法。但是,当我在Navicat中运行以下查询时,我得到一个错误 问题是:SQL Server XQuery语法错误,sql,sql-server,tsql,xquery,serilog,Sql,Sql Server,Tsql,Xquery,Serilog,我正在为SQLServer使用Serilog接收器,并使用link遵循DB模式和XQuery语法。但是,当我在Navicat中运行以下查询时,我得到一个错误 问题是: SELECT Properties.value('(/properties/property[@key="contact"]/structure[@type="Contact"]/property[@key="ContactId"])[1]', 'nvarchar(max)') AS ContactId, Properties.
SELECT
Properties.value('(/properties/property[@key="contact"]/structure[@type="Contact"]/property[@key="ContactId"])[1]', 'nvarchar(max)') AS ContactId,
Properties.value('(/properties/property[@key="contact"]/structure[@type="Contact"]/property[@key="FirstName"])[1]', 'nvarchar(50)') AS FirstName,
Properties.value('(/properties/property[@key="contact"]/structure[@type="Contact"]/property[@key="Surname"])[1]', 'nvarchar(100)') AS Surname,
Properties.value('(/properties/property[@key="cacheKey"])[1]', 'nvarchar(100)') AS CacheKey,
*
FROM Log
WHERE MessageTemplate = 'Contact {@contact} added to cache with key {@cacheKey}'
AND Properties.value('(/properties/property[@key="contact"]/structure[@type="Contact"]/property[@key="ContactId"])[1]', 'nvarchar(max)') = 'f7d10f53-4c11-44f4-8dce-d0e0e22cb6ab'
以下是错误声明:
[Err]42000-[SQL Server]找不到列“Properties”或用户定义的函数或聚合“Properties.value”,或者名称不明确
非常感谢任何解决方案或解决方法。若日志表有Properties列且其格式为XML,则将运行查询 因此,您必须更改列的类型或在查询中将其转换为XML
第二种方法类似于
cast(属性为xml)。value
…是columnProperties
格式为xml吗?如果Log
表有Properties
列且其格式为XML,则将运行查询。不,它不是。。。