2

how can i find and split a value between double quotation Value is like this :

'<Relations mfrid="EnvoeyName_MFR"><Form EC="180" ETC="711" Val="1679" /></Relations>'

value is one filed of table and i want split "EC,ETC,Val" value i mean 180,711,1679

thanks for your help

Javad Abedi
  • 492
  • 1
  • 6
  • 21
  • I assume you are trying to extract the attribute values from an XML datatype. See [this](https://stackoverflow.com/questions/8808652/sql-how-can-i-get-the-value-of-an-attribute-in-xml-datatype) question. Googling "t-sql xml query attribute value" will give other examples. – Peter Smith Aug 30 '18 at 07:05

1 Answers1

2

You Can try the following

DECLARE @XMLData XML = '<Relations mfrid="EnvoeyName_MFR"><Form EC="180" ETC="711" Val="1679" /></Relations>'

SELECT
    EC = Node.Data.value('@EC', 'INT'),
    ETC = Node.Data.value('@ETC', 'INT'),
    Val = Node.Data.value('@EC', 'INT')
    FROM @XMLData.nodes('/Relations/Form') Node(Data)
Jayasurya Satheesh
  • 7,826
  • 3
  • 22
  • 39
  • hey buddy , i have another question when i execute that query , I found some value like this :
    so that code can't get EC value from tag Form
    – Javad Abedi Aug 30 '18 at 08:02
  • I'm able to get the values even if there are multiple Tags, so there might be some issue with your tag or query. Can you share more details ? – Jayasurya Satheesh Aug 30 '18 at 08:56