title: Storing HASHBYTES output in NVARCHAR vs BYTES
body: <p>I am going to create:</p>
  
  <ul>
  <li>a table for storing IDs and unique text values (which are expected to
  be large)</li>
  <li>a stored procedure which will have a text value as input parameter
  (it will check if the value exists in the above table and return the
  corresponding ID if it exists, or inserted a new record if not and
  return the new ID as well)</li>
  </ul>
  
  <p>I want to optimize the search of text values using hash value of the text and created index on it. So, during the search I expect a non-clustered index to be used (not the clustered index). </p>
  
  <p>I decided to use the <a href="https://msdn.microsoft.com/en-us/library/ms174415.aspx" rel="nofollow">HASHBYTES</a> with <code>SHA2_256</code> and I am wondering are there any differences/benefits if I am storing the hash value as <code>BINARY(32)</code> or <code>NVARCHAR(16)</code>?</p>