Another method I found is using ROW_NUMBER function to arbitrarily join the tables, then use that derived query to update the FK. The idea is there isnt a relationship yet between tableA and tableB we just need link them to grab the new foreign keys. Joining them on something arbitrary like ROW_NUMBER gives us a method to pick out a single row to grab the Id from.
Create the new records first
INSERT INTO TableB VALUES (value1)
Write the query that arbitrarily joins them on ROW_NUMBER (we use this in the next step)
SELECT
tableARows.Id,
tableBRows.TheNewId
FROM
(
SELECT Id, Row = ROW_NUMBER() OVER (ORDER BY Id) FROM tableA
)tableARows INNER JOIN
(
SELECT TheNewId, Row = ROW_NUMBER() OVER (ORDER BY TheNewId) FROM tableB
)tableBRows ON tableARows.Row = tableBRows.Row
And then a full UPDATE statement to populate tableA with new FK's from tableB
UPDATE tableA
SET tableA.ForeignKey = LinkedKeys.TheNewId
FROM
(
SELECT
tableARows.Id,
tableBRows.TheNewId
FROM
(
SELECT Id, Row = ROW_NUMBER() OVER (ORDER BY Id) FROM tableA
)tableARows INNER JOIN
(
SELECT TheNewId, Row = ROW_NUMBER() OVER (ORDER BY TheNewId) FROM tableB
)tableBRows ON tableARows.Row = tableBRows.Row
)LinkedKeys INNER JOIN
tableA ON tableA.Id = LinkedKeys.Id
Here are example table definitions I used.
CREATE TABLE tableA (Id INT, ForeignKey INT)
INSERT INTO tableA VALUES (100,NULL),(200,NULL),(300,NULL)
CREATE TABLE tableB (TheNewId INT)
INSERT INTO tableB VALUES(5000),(6000),(7000)