【发布时间】:2013-11-25 13:35:32
【问题描述】:
我正在运行的查询无法正常运行,这是我的代码:
select a.id, a.userid, c.firstname + ' ' + c.lastname AS Name, a.objectid, a.settings,
CAST(settings as XML).exist('property[@name=''colFirstChoiceVendorPaymentTerms'']') as first,
CAST(settings as XML).exist('property[@name="colSecondChoiceVendorPaymentTerms"]//property[@name=''Visible'' and text()=''true'']') as second,
CAST(settings as XML).exist('property[@name="colThirdChoiceVendorPaymentTerms"]//property[@name=''Visible'' and text()=''true'']') as third
FROM wcukopera05.vstx.dbo.screenlayout a
join wcuksql01.hrsystem.dbo.person c
on a.UserId=c.Id
where a.objectid = 'gridViewCustomerCurrentRatesCosts'
我有一段很长的 XML,我想检查 XML 中是否存在某些属性,例如 (colThirdChoiceVendorPaymentTerms) 并查看可见性是否为真。
此时我的代码返回所有正确的列,但列“第一”、“第二”和“第三”的值都返回 0。但其中一些应该返回 1...
我不明白为什么它们都返回 0?
我已在此处上传 XML:txt.do/dev1,您将看到 colFirstChoiceVendorPaymentTerms 和 colSecondChoiceVendorPaymentTerms 的可见性设置为 true。但是 colThirdChoiceVendorPaymentTerms 没有可见性。这就是我要检查的。可见性和列是否存在。
再次感谢您的帮助。
【问题讨论】:
标签: c# mysql sql sql-server xml