title: Insert into edge table in SQL Server 2017
body: <p>Currently I'm trying to learn the graph database features of SQL Server 2017, and for this purpose I am trying to load a set of current data into a set of node and edge tables.</p>
  
  <p>I have not had issues loading into node tables from a <code>SELECT</code> query. But I am encountering trouble when trying to load data into my edges table.</p>
  
  <p>I have a table named kontomappingDetaljeret, that contains kontoNummer and refNr</p>
  
  <p>I also have node tables containing these features as nodes. I am trying to map the relationship between the kontoNummer and refNr columns.</p>
  
  <p>So far I have this query that does not execute</p>
  
  <pre><code>INSERT INTO brugtIRef 
  VALUES 
      ((SELECT $node_id FROM o90Konto WHERE kontoNummer = konti.konto),
       (SELECT $node_id FROM refNummer WHERE refNr = konti.refNr))
  FROM
      KontomappingDetaljeret konti
  INNER JOIN
      o90Konto ON konti.konto = o90Konto.kontoNummer
  INNER JOIN
      refNummer ON konti.refNr = refNummer.refNr
  </code></pre>
  
  <p>EDIT</p>
  
  <p>WHEN Running the following query I get this result</p>
  
  <pre><code>SELECT TOP (10)
      (SELECT $node_id FROM dbo.o90Konto WHERE kontoNummer = konti.konto) AS KontoNr,
      (SELECT $node_id FROM dbo.refNummer WHERE refNr = konti.refNr) AS refNr
  
  FROM
      KontomappingDetaljeret konti
  
  INNER JOIN
      dbo.o90Konto
  ON 
      konti.konto = o90Konto.kontoNummer
  
  INNER JOIN
      dbo.refNummer
  ON 
      konti.refNr = refNummer.refNr
  </code></pre>
  
  <p>Results in</p>
  
  <pre><code>KontoNr refNr
  {"type":"node","schema":"dbo","table":"o90Konto","id":180657}   {"type":"node","schema":"dbo","table":"refNummer","id":0}
  {"type":"node","schema":"dbo","table":"o90Konto","id":211723}   {"type":"node","schema":"dbo","table":"refNummer","id":1}
  {"type":"node","schema":"dbo","table":"o90Konto","id":216400}   {"type":"node","schema":"dbo","table":"refNummer","id":2}
  {"type":"node","schema":"dbo","table":"o90Konto","id":205844}   {"type":"node","schema":"dbo","table":"refNummer","id":3}
  {"type":"node","schema":"dbo","table":"o90Konto","id":388939}   {"type":"node","schema":"dbo","table":"refNummer","id":4}
  {"type":"node","schema":"dbo","table":"o90Konto","id":536204}   {"type":"node","schema":"dbo","table":"refNummer","id":5}
  {"type":"node","schema":"dbo","table":"o90Konto","id":130331}   {"type":"node","schema":"dbo","table":"refNummer","id":6}
  {"type":"node","schema":"dbo","table":"o90Konto","id":83983}    {"type":"node","schema":"dbo","table":"refNummer","id":7}
  {"type":"node","schema":"dbo","table":"o90Konto","id":344522}   {"type":"node","schema":"dbo","table":"refNummer","id":7}
  {"type":"node","schema":"dbo","table":"o90Konto","id":523743}   {"type":"node","schema":"dbo","table":"refNummer","id":7}
  </code></pre>
  
  <p>I just need some way to insert this result into the edges table</p>