Querying XML Datatype Column

  • with the xml below, how can i use a select statement to extract

    the option name?

    this is the first time im exposed to xml in a db so any help is appreciated.

    thanks

  • anyone?

  • Does this get you started in the right direction?

    DECLARE @myvar AS XML

    , @XMLDoc int

    SELECT @myvar = '

    &ltMovement xmlns="" Context="Acquire"&gt

    &ltOperationCollection&gt

    &ltOperation Name = "Execute"&gt

    &ltOptionCollection&gt

    &ltOption Name="Execution.Capability"&gt(Synchronous,Asynchronous)&lt/Option&gt

    &ltOption Name="Execution.Preference"&gt(Asynchronous)&lt/Option&gt

    &ltOption Name="Origin.Status.Criteria"&gt(Fail)&lt/Option&gt

    &lt/OptionCollection&gt

    &lt/Operation&gt

    &ltOperation Name="ConnectorContext"&gt

    &ltOptionCollection&gt

    &ltOption Name="Connector.MerchantIdentifier"&gt56500&lt/Option&gt

    &ltOption Name="Connector.Alias"&gtCC_01&lt/Option&gt

    &ltOption Name="Connector.Wallet.TransactionIdentifier"&gt(wirecard:Transaction)(00000000000000000000000001xP2)()&lt/Option&gt

    &ltOption Name="Connector.TrasactionIdentifier"&gt(wirecard:Transaction)C242720181323966504820)()&lt/Option&gt

    &ltOption Name="Connector.Context"&gtwirecard&lt/Option&gt

    &lt/OptionCollection&gt

    &lt/Operation&gt

    &lt/OperationCollection&gt

    &lt/Movement&gt

    '

    EXEC sp_xml_preparedocument @XMLDoc OUTPUT, @myvar

    SELECT *

    FROM OPENXML(@XMLDoc, '/Movement/OperationCollection/Operation/OptionCollection/Option', 1)

    WITH (NAME varchar(100) '@Name')

    Hope this helps!

    Chad

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply