title: Need to change GUID to varchar or char
body: <p>I am trying to use a reference table to update a code, but I am getting the error:</p>
  
  <blockquote>
    <p>Conversion failed when converting from a character string to
    uniqueidentifier</p>
  </blockquote>
  
  <p>The ID is a guid: <strong>086B9FE7-3980-47D7-BB05-003708F1D564</strong> and the reference code I want to use is 4 characters, like <strong>H100</strong>.  </p>
  
  <p>I received the initial error when I tried to alter the datatype in the table and then update the file with the values from the reference table. I have tried converting and casting based on other articles, but even if I cast or convert successfully, I still get the same message.</p>
  
  <p><strong>RefTable:</strong></p>
  
  <pre><code>Id                                   |  ReportCode
  6340FCEA-161C-42F4-8D7F-46B4C2E6C4E2 |  H100
  </code></pre>
  
  <p><strong>DataTable:</strong></p>
  
  <pre><code>CauseId
  6340FCEA-161C-42F4-8D7F-46B4C2E6C4E2
  </code></pre>
  
  <p>Code I am using to try and update. The first works, and the second bring the error msg:</p>
  
  <pre><code>select cast(nvarchar(36), ID) as ID
  from [dbo].[reftable]
  
  UPDATE dbo.datatable
  SET    causeid = L.reportcode
  FROM   dbo.datatable S 
  join dbo.reftable L on S.causeid = L.id
  </code></pre>