[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1017
  • Last Modified:

SQL Server - Select attribute from XML Field

I have an field as an XML datatype.  I want to parse out a particular attribute.

See the start of the XML data.  How do I parse out, via SQL, just the "requestMachineName" data?


<UnitCheckInRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" requestUserIdentity="sample"
requestMachineName="sampleMachine"
0
EricLynnWright
Asked:
EricLynnWright
  • 3
1 Solution
 
EricLynnWrightAuthor Commented:
select UnitCheckInXmlMessage.value('(/UnitCheckInRequest/@requestMachineName)[1]','varchar(20)') as Machine Name
  from UnitCheckInTransaction
0
 
fritzfrancisCommented:
SELECT  ColumnName.value('(/UnitCheckInRequest/@requestMachineName)[1]', 'varchar')
FROM TableName
0
 
EricLynnWrightAuthor Commented:
Sorry.  With the help you gave me from the other question, I was able to find it.

Thanks again for all the help!  I greatly appreciate it.
0
 
EricLynnWrightAuthor Commented:
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now