title: SQL: Convert an integer into a hex string?
body: <p>How do you convert an integer into a string of hex?
  I want to convert the int into a format that I can use as a color on my page for example '#ff0000'.</p>
  
  <p>So for example:</p>
  
  <pre><code>--This converts my int to hex:
  CONVERT(VARBINARY(8), Color) Color,
  </code></pre>
  
  <p>And I want to do something like this:</p>
  
  <pre><code>'#' + CONVERT(NVARCHAR(10), CONVERT(VARBINARY(8), Color)) Color
  </code></pre>
  
  <p>But converting a varbinary string just converts it to an ascii character rather than returning the actual hex string</p>