patternsqlMinor
OPENXML question for SQL Server
Viewed 0 times
sqlopenxmlforserverquestion
Problem
I am brand new to OPENXML, and have 90 % of what I want to do working...stuck on this:
My Desired results:
I am able to get the name value ("Host_end", etc.), but not the content.
My query:
I'd like to stick with OPENXML if at all possible, since I just spent the day learning it and getting to this final step.
Please let me know if I have provided enough info.
Wed Nov 11 20:48:43 2015
8675309
true
AWT v6
MyPassword
MyLogin
ssh
411.114.42.42
Wed Nov 11 20:00:01 2015
My Desired results:
Wed Nov 11 20:48:43 2015
8675309
TRUE
AWT v6
MyPassword
MyLogin
ssh
411.114.42.42
Wed Nov 11 20:00:01 2015I am able to get the name value ("Host_end", etc.), but not the content.
My query:
Select *
from OPENXML (@hdoc,'/ReportHost/HostProperties/tag',1)
WITH (
name varchar (500)
)I'd like to stick with OPENXML if at all possible, since I just spent the day learning it and getting to this final step.
Please let me know if I have provided enough info.
Solution
You need to query for
nodetype 3 to get the element text. I have changed your xpath expression slightly so it just returns the node textEXEC sp_xml_preparedocument @hdoc OUTPUT, @XmlDocument
Select [text]
from OPENXML (@hdoc,'/ReportHost/HostProperties/tag/text()',3)Code Snippets
EXEC sp_xml_preparedocument @hdoc OUTPUT, @XmlDocument
Select [text]
from OPENXML (@hdoc,'/ReportHost/HostProperties/tag/text()',3)Context
StackExchange Database Administrators Q#122599, answer score: 6
Revisions (0)
No revisions yet.