title: Cast nvarchar to tinyint
body: <p>I'm kinda new to SQL coding and I am trying to select a <code>nvarchar</code> value and insert it into a <code>tinyint</code> column.</p>
  
  <p>I use the following query </p>
  
  <pre><code>insert into COV (GID, DocumentNumber, RegistrationDate, CustomerCode, CustomerName, DeliveryDateAndTime, LineGID, Item, Quantity, DeliveryDate, MU, ExportedToSchnell)
      select 
          esd.GID, esd.ADCode, esd.ADRegistrationDate, esc.Code, esc.Name,
          esd.DeliveryDueDate, esfl.GID, esf.Code, esfl.Quantity,  
          esfl.DeliveryDate, esmm.fMUCode, esfl.Stringfield1 
      from 
          ESFIDocumentTrade esd
      left join 
          ESFITradeAccount esc on esd.fTradeAccountGID = esc.GID
      left join 
          ESFIDocumentType est on esd.fADDocumentTypeGID = est.GID
      left join 
          ESFILineItem esfl on esfl.fDocumentGID = esd.GID
      left join 
          ESFIItem esf on esf.GID = esfl.fItemGID
      left join 
          ESMMItemMU esmm on esmm.fItemGID = esf.GID
      where 
          est.Code = 'COV' 
          and esfl.StringField1 = 'YES' 
          and esd.ADRegistrationDate &gt; '2017-02-01'
  </code></pre>
  
  <p>But I get the following error:</p>
  
  <blockquote>
    <p>Conversion failed when converting the nvarchar value 'YES' to data type tinyint.</p>
  </blockquote>
  
  <p>I have tried to cast the <code>nvarchar</code> column but I cannot figure it out how to do it.</p>
  
  <p>Can you help me? Thanks</p>