Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The only viable approach I see is trying to do this:</p> <ul> <li>parse/shred your XML arrays into temporary tables for phones and addresses</li> <li>those temporary tables have an <code>ID INT IDENTITY</code> defined</li> <li>when inserting into a fresh temporary table with this INT IDENTITY, both sets of data will get consecutive numbering (1, 2, 3, 4......) </li> <li>you can then join the two temporary tables on their ID and should get your "lock-step" behavior:</li> </ul> <p>So in code, this would look something like (mind you: your XML is invalid, too - the attribute values need to be in double quotes for this to work!):</p> <pre><code>DECLARE @phones XML = '&lt;PhoneID Value="128"/&gt;&lt;PhoneID Value="129"/&gt;&lt;PhoneID Value="130"/&gt;' DECLARE @Addresses XML = '&lt;AddressID Value="268"/&gt;&lt;AddressID Value="157"/&gt;&lt;AddressID Value="395"/&gt;' DECLARE @phoneTable TABLE (ID INT IDENTITY PRIMARY KEY, PhoneID INT) DECLARE @AddressTable TABLE (ID INT IDENTITY PRIMARY KEY, AddressID INT) INSERT INTO @phoneTable(PhoneID) SELECT PHID.value('(@Value)', 'int') FROM @phones.nodes('/PhoneID') AS PH(PHID) INSERT INTO @AddressTable(AddressID) SELECT ADRID.value('(@Value)', 'int') FROM @addresses.nodes('/AddressID') AS AD(ADRID) SELECT p.*, a.* FROM @phoneTable p INNER JOIN @addresstable a ON p.ID = a.ID </code></pre> <p>Does that work for you?? From here, you could then insert the data into your actual working tables and do any additional lookups or processing.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload