Home TSQL XML locate particular block(s)
Reply: 0

TSQL XML locate particular block(s)

user1687 Published in July 17, 2018, 7:58 am

SET @XMLData = '<ArrayOfAttributeValueDO>
        <AttributeValue>100% cotton pre-shrunk drill</AttributeValue>
        <AttributeValue>Long Sleeve</AttributeValue>

Given the above example, how can I get a particular <AttributeValueDO> by searching on the <AttributeID> and <AttributeValue>?

I am kind of expecting syntax like this but having error in between "[]" In fact, I am trying to get any <AttributeValueDO> with attributeID of 422 and attributeValue contains word of 'gsm'

DECLARE @strAttributeID VARCHAR(1000) = '422'
DECLARE @strAttributeValue VARCHAR(1000) = '190gsm'

SELECT [AttributeValueXML] 
FROM [dbo].[tbl_Stock_Master_AttributeValue] 
WHERE [AttributeValueXML].exist('(/ArrayOfAttributeValueDO/AttributeValueDO[AttributeID=sql:variable("@strAttributeID") && AttributeValue=sql:variable("@strAttributeValue")])') = 1
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.402136 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO