title: Replace IDs that are stored as json in varchar columns
body: <p>I have a pretty big table ~ 20 million rows in a SQL server 2008R2 database that contains a VARCHAR(MAX) column with json data in it. The json-data points out IDs in other tables.</p>
  
  <p>I have received a task to consolidate 3 databases into 1 single database and since the IDs are BIGINT identities it is impossible to recreate them with the same ID as in the old DB.</p>
  
  <p>My question is:
  How do i migrate the json-data to point out the correct new IDs in the shortest amount of execution time? I have created all rows in the new database to also contain the ID of the row in the old DBs so I have no problem with that. But i do not find a way to extract the actual IDs from the varchar and replace them.</p>
  
  <p>Example json:</p>
  
  <blockquote>
    <p>[{"TriggerCriteriaID":960,"Values":{"LatestDepositValue":1000.0000,"TransactionFeedID":331449169,"TriggerFinishedDate":"2015-07-25T21:41:22"}},{"TriggerCriteriaID":961,"Values":{"LatestDepositValue":1200.0000,"ActionFeedID":312,"TriggerFinishedDate":"2015-07-25T21:41:22"}}]</p>
  </blockquote>
  
  <p>It is the following entities that have new IDs that needs replacement:</p>
  
  <ul>
  <li>TriggerCriteriaID (May exist multiple times in the json)</li>
  <li>TransactionFeedID</li>
  <li>ActionFeedID</li>
  </ul>
  
  <p>Thanks in advance!</p>